我不相信你会得到约束工作。让 ChildWindow 填满屏幕的最简单方法是将 HorizontalAlignment 和 VerticalAlignment 设置为 Stretch
<controls:ChildWindow x:Class="SilverlightApplication4.ChildWindow1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
Title="ChildWindow1"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
如果您绝对想在 silverlight 中使用 ActualWidth/ActualHeight 路线,您必须执行类似...
public ChildWindow1()
{
InitializeComponent();
UpdateSize( null, EventArgs.Empty );
App.Current.Host.Content.Resized += UpdateSize;
}
protected override void OnClosed( EventArgs e )
{
App.Current.Host.Content.Resized -= UpdateSize;
}
private void UpdateSize( object sender, EventArgs e )
{
this.Width = App.Current.Host.Content.ActualWidth;
this.Height = App.Current.Host.Content.ActualHeight;
this.UpdateLayout();
}