【发布时间】:2015-06-17 11:37:06
【问题描述】:
我正在开发 Windows 8.1 应用商店应用程序,在一个页面上我需要在横向模式下设置 MyControl.Width = 450,但在纵向模式下我希望控件伸展到所有可用空间。 作为一种解决方法,可以使用 HorizontalAlighment Right vs Stretch with MinWidth,但我对 VisualState Storyboards 的解决方案感兴趣。
使用 ObjectAnimationUsingKeyFrames 很容易设置特定的宽度,如下所示:
<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="MyControl" Storyboard.TargetProperty="Width">
<DiscreteObjectKeyFrame KeyTime="0" Value="450" />
</ObjectAnimationUsingKeyFrames>
但我不知道如何在此处设置 DependencyProperty.UnsetValue,换句话说,将属性设置为默认的未设置值。注意我正在寻找 Windows 8.1 应用程序中的解决方案。在 WPF XAML 中可能很容易实现,但在 Windows 8.1 XAML 中有点受限。谢谢
【问题讨论】:
-
您可以在后面的代码中使用“Page_SizeChanged”事件来实现。
标签: xaml windows-runtime winrt-xaml visualstatemanager