Reputation: 3294
I have a grid control, two rows and two columns.
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition x:Name="row1"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition x:Name="column1"/>
</Grid.ColumnDefinitions>
</Grid>
Now I have another , by default it's position is in row1. When the window width is larger than 1024, I want to set gridX's position to column1.
I just want to know the change position code, thanks.
Upvotes: 0
Views: 514
Reputation: 39072
Universal Windows Platform offers AdaptiveTriggers
just for this purpose.
Under the root content element of your page (usually a Grid
) you define VisualState
, that is controlled by an AdaptiveTrigger
and is displayed when the window width is greater than 1024 effective pixels. The Setters
then control the changes that should be performed when transitioning between the states.
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState>
<VisualState.StateTriggers>
<AdaptiveTrigger MinWindowWidth="1024"/>
</VisualState.StateTriggers>
<VisualState.Setters>
<Setter Target="gridX.(Grid.Column)" Value="1"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
Because Grid.Column
is an attached property, you need to wrap it in parentheses in the Setter
's Target
. The sample code supposes that your grid has a x:Name="gridX"
attribute.
Upvotes: 1