首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

WPF里Popup如何大到一定限度就显示不完整了呢

2013-02-24 
WPF里Popup怎么大到一定限度就显示不完整了呢?Window x:ClassPopupTest.MainWindowxmlnshttp://sche

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>
                <RowDefinition Height="Auto" />


                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>


[解决办法]
popup 窗口里面控件left,top位置的书写是否注意了?
[解决办法]

仅供参考。
grid放在window里,window的size限制了grid的size,你是不是window不够大?
[解决办法]
我也遇到了,可惜没人回复。
http://bbs.csdn.net/topics/390360261
同求解决方案。

貌似这个问题还挺普遍http://stackoverflow.com/questions/2633129/cant-create-a-fullscreen-wpf-popup

我准备先试试用2个popup拼接起来看能行不。实在不行只能用窗体来实现了。

热点排行