Silverlight 4和浏览器

有没有人知道它是否可以动画app.current.mainwindow.width,这样如果你以编程方式调整oob应用程序窗口的大小,你就可以获得一个很好的动画.

谢谢. 最佳答案 最简单的方法是向页面添加滑块控件.滑块可以折叠,仅用于轻松实现动画效果.为滑块的Value属性设置动画.在滑块的ValueChanged事件中更新窗口宽度.你需要提升推力才能做到这一点.

它看起来像这样:

XAML

<UserControl.Resources>
  <Storyboard x:Name="Storyboard1">
    <DoubleAnimation Duration="0:0:1" To="750" 
                     Storyboard.TargetProperty="(RangeBase.Value)" 
                     Storyboard.TargetName="slider1">
      <DoubleAnimation.EasingFunction>
        <BounceEase EasingMode="EaseOut"/>
      </DoubleAnimation.EasingFunction>
    </DoubleAnimation>
  </Storyboard>    
</UserControl.Resources>

<Grid x:Name="LayoutRoot" Background="Green">
  <Button Width="50" Height="32" Click="Button_Click">Test</Button>
  <Slider Visibility="Collapsed" VerticalAlignment="Bottom" 
          x:Name="slider1" Maximum="1000" 
          ValueChanged="slider1_ValueChanged" />
</Grid>

代码背后

private void Button_Click(object sender, RoutedEventArgs e)
{
    Storyboard1.Begin();
}

private void slider1_ValueChanged(object sender, 
                                  RoutedPropertyChangedEventArgs<double> e)
{
    Application.Current.MainWindow.Width = e.NewValue;
}
点赞