I'm a beginner working a C# Windows 8 app. I have a RichEditBox in the center of the screen whose width changes depending on the window size. I can set the width of this RichEditBox to Auto
by editing its own properties, but I want to set the width to Auto
when the width of the window falls below a certain point. I'm using VisualState
s to define the various screen options. The problem is that when I set the value to Auto
, the app will crash when it tries to invoke the new VisualState
.
My code is as follows:
<VisualStateGroup x:Name="ApplicationViewStates">
<VisualState x:Name="FlexibleViewState">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Editor" Storyboard.TargetProperty="Width">
<DiscreteObjectKeyFrame KeyTime="0" Value="Auto"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
I don't know why it's doing this. I can do the following without any problems:
<RichEditBox x:Name="Editor" Width="Auto"/>
But when I try to set the width to Auto
with a VisualState
it crashes. Is there any way to fix this or to work around this problem?