Silverlight 4 and out of browser

十年热恋 提交于 2020-02-02 04:07:57

问题


Does any one know if its possible to animate app.current.mainwindow.width so that you get a nice animation with easing if you programatically resize the oob apps window. Thanks.


回答1:


The simplest way is to add a slider control to your page. The slider can be collapsed and is only used to have an easy propery to animate. Animate the Value property of the slider. In the ValueChanged event of the slider update the window width. You need elevated thrust to do this.

It looks something like this:

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>

Code Behind

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;
}



回答2:


You should check out this Channel 9 presentation for customizing the window chrome in out-of-browser support. Your application requires elevated trust to customize the chrome, but this might enable you to do what you want to do.



来源:https://stackoverflow.com/questions/2527490/silverlight-4-and-out-of-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!