这确实是个很奇怪的问题。 我在stackoverflow上找到的唯一相关的解释:Some of these top level properties on Window are a bit weird and don't behave the same way as other WPF properties because they're on the boundary of Win32.如果你必须要实现你想要的效果,有两种方法可以尝试。 1. 尝试自已定义依赖属性,关联windows的Height and Width. 2. 不使用Animation,自己用Timer去实现Height and Width的变化。
我在stackoverflow上找到的唯一相关的解释:Some of these top level properties on Window are a bit weird and don't behave the same way as other WPF properties because they're on the boundary of Win32.如果你必须要实现你想要的效果,有两种方法可以尝试。
1. 尝试自已定义依赖属性,关联windows的Height and Width.
2. 不使用Animation,自己用Timer去实现Height and Width的变化。
<Grid Width="100" Height="100" x:Name="xx" SizeChanged="xx_SizeChanged_1">
<Grid.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Width" To="900" Duration="0:0:5" BeginTime="0:0:0" FillBehavior="HoldEnd" AutoReverse="False" />
<DoubleAnimation Storyboard.TargetProperty="Height" To="500" Duration="0:0:5" BeginTime="0:0:0" FillBehavior="HoldEnd" AutoReverse="False"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Grid.Triggers>
</Grid>在sizeChanged事件里面去改window的宽高,不过会有黑边。。哎~~