How to set DependencyProperty.UnsetValue in VisualState Storyboard in WinRT app?

119 views Asked by At

I'm developing Windows 8.1 Store app and on one page I need to set in landscape mode MyControl.Width = 450, but in Portrait I want the control to stretch into all available space. As a workaround it could be possible to use HorizontalAlighment Right vs Stretch with MinWidth, but I'm interested in a solution with VisualState Storyboards.

It's easy to set specific Width using ObjectAnimationUsingKeyFrames like this:

<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="MyControl" Storyboard.TargetProperty="Width">
    <DiscreteObjectKeyFrame KeyTime="0" Value="450" />
</ObjectAnimationUsingKeyFrames>

But I have no idea, how to set DependencyProperty.UnsetValue here, in other words to set the property to default, unset value. Note I'm looking for solution in Windows 8.1 app. It might be easily possible in WPF XAML, but in Windows 8.1 XAML is a bit limited. Thanks

1

There are 1 answers

0
DrewCan On

This snippet looks like the content of a single VisualState. Each VisualState in the same VisualStateGroup will be mutually exclusive. If you have one state that doesn't modify the Width property in the same VisualStateGroup as the one that does then you should be able to GoToState between the two and effectively set/unset the value.