I'm trying to modify the MaximumRowsOrColumns property of my WrapGrid like this:
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid x:Name="wrapGridItems" Orientation="Vertical" MaximumRowsOrColumns="1" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
And then I'm using this code to change the WrapGrid:
<VisualState x:Name="Snapped">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="wrapGridItems" Storyboard.TargetProperty="MaximumRowsOrColumns">
<DiscreteObjectKeyFrame KeyTime="0" Value="-1"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="headerText" Storyboard.TargetProperty="Text">
<DiscreteObjectKeyFrame KeyTime="0" Value="Pins"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
But I'm getting the error
WinRT information: Cannot resolve TargetName wrapGridItems.
How should I refer to the WrapGrid in the ObjectAnimationUsingKeyFrames Storyboard.TargetName property?
You can not access elements inside templates using x:Name. Since template could be instantiated many times animation wouldn't be able to tell which element it should manipulate.
If you need to change property of element inside the template you should use binding:
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid Orientation="Vertical" MaximumRowsOrColumns="{Binding MyMaxRowsOrCollumns}" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With