Silverlight 4 和浏览器外

发布于 2024-08-26 22:50:52 字数 95 浏览 6 评论 0原文

有谁知道是否可以对 app.current.mainwindow.width 进行动画处理,以便在以编程方式调整 oob 应用程序窗口大小时获得一个带有缓动的漂亮动画。 谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一瞬间的火花 2024-09-02 22:50:52

最简单的方法是向页面添加滑块控件。滑块可以折叠,仅用于具有简单的动画属性。对滑块的 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;
}

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;
}
冷情 2024-09-02 22:50:52

您应该查看此 Channel 9 演示文稿以自定义窗口镶边在浏览器外支持中。您的应用程序需要更高的信任度才能自定义镶边,但这可能使您能够做您想做的事情。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文