日期:2014-05-17  浏览次数:20829 次

WPF里Popup怎么大到一定限度就显示不完整了呢?
<Window x:Class="PopupTest.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow">
    <Grid x:Name="M" Background="Gray" MouseLeftButtonDown="M_MouseLeftButtonDown_1">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="0"/>
        </Grid.ColumnDefinitions>
        <Grid x:Name="Left" Grid.Column="1"/>
        <Popup x:Name="pop" 
               Placement="Left"
               PlacementTarget="{Binding ElementName=Left}"
               Height="{Binding ActualHeight, ElementName=M}"
               Width="{Binding ActualWidth, ElementName=M}">
            <Grid Background="Red">
            </Grid>
        </Popup>
    </Grid>
</Window>



using System;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Input;

namespace PopupTest
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        private void M_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
        {
            pop.IsOpen = !pop.IsOpen;
        }
    }
}

最大化或者拖到很大之后下面就有一部分显示不出来
为什么呢。。

------解决方案--------------------
不知道你碰到的是不是这种问题
------解决方案--------------------
Height="{Binding?ActualHeight,?ElementName=M}"
???????????????Width="{Binding?ActualWidth,?ElementName=M}">
这句是错的吧,因为Popup根本不知道需要多大尺寸,他哪里来的ActualWidth和Height,你需要让里面的内容顶出去
里面的Grid尤其要注意Height的问题

            <Grid.RowDefinitions>
           &nb