title: UWP Visual State Manager Change Grid Row Height
body: <p>I am using a <code>VisualStateManager</code> in the XAML to specify a change in the width/height of a grid column/row by using the <code>ColumnDefinition</code> and <code>RowDefinition</code> <code>x:Name</code> properties. I read <a href="https://metronuggets.com/2015/06/23/use-triggers-to-change-grid-columnrow-values-in-universal-windows-apps/" rel="nofollow noreferrer">here</a> that this is possible... but Visual Studio says "Failed to find element named _____" with a warning, and the state change for the grid row does not work (the setters for changing row/column assignments trigger correctly, so I know the <code>VisualStateManager</code> is working overall).</p>
  
  <p>The intended effect is to have the content vertically take up exactly the screen (with no vertical scrolling) in the wide state, with each block being in a different column. Then in the narrow state, the content will reflow to instead be all in the same column but different rows (thus vertically stacked), and thus vertical scrolling will be necessary (the content will also change from having a fixed width in the wide state, to stretching to take up the window width in the narrow state).</p>
  
  <p>My code looks something like this:</p>
  
  <pre><code>&lt;Page&gt;
      &lt;Grid&gt;
          &lt;VisualStateManager.VisualStateGroups&gt;
              &lt;VisualStateGroup x:Name="VisualStateGroup"&gt;
                  &lt;VisualState x:Name="Narrow"&gt;
                      &lt;VisualState.StateTriggers&gt;
                          &lt;AdaptiveTrigger MinWindowWidth="0"&gt;&lt;/AdaptiveTrigger&gt;
                      &lt;/VisualState.StateTriggers&gt;
                      &lt;VisualState.Setters&gt;
                          &lt;Setter Target="ContentBlockA.(Grid.Column)" Value="0"&gt;&lt;/Setter&gt;
                          &lt;Setter Target="ContentBlockB.(Grid.Column)" Value="0"&gt;&lt;/Setter&gt;
                          &lt;Setter Target="ContentBlockC.(Grid.Column)" Value="0"&gt;&lt;/Setter&gt;
                          &lt;Setter Target="ContentBlockA.(Grid.Row)" Value="2"&gt;&lt;/Setter&gt;
                          &lt;Setter Target="ContentBlockB.(Grid.Row)" Value="1"&gt;&lt;/Setter&gt;
                          &lt;Setter Target="ContentBlockC.(Grid.Row)" Value="0"&gt;&lt;/Setter&gt;
                          &lt;Setter Target="ContentRowZero.Height" Value="Auto"&gt;&lt;/Setter&gt;
                          &lt;Setter Target="ContentColumnZero.Width" Value="*"&gt;&lt;/Setter&gt;
                      &lt;/VisualState.Setters&gt;
                  &lt;/VisualState&gt;
                  &lt;VisualState x:Name="Wide"&gt;
                      &lt;VisualState.StateTriggers&gt;
                          &lt;AdaptiveTrigger MinWindowWidth="900"&gt;&lt;/AdaptiveTrigger&gt;
                      &lt;/VisualState.StateTriggers&gt;
                      &lt;VisualState.Setters&gt;
                          &lt;!-- Empty setters defaults to the layout specified in XAML below. --&gt;
                      &lt;/VisualState.Setters&gt;
                  &lt;/VisualState&gt;
              &lt;/VisualStateGroup&gt;
          &lt;/VisualStateManager.VisualStateGroups&gt;
  
          &lt;ScrollViewer&gt;
              &lt;Grid&gt;
                  &lt;Grid.ColumnDefinitions&gt;
                      &lt;ColumnDefinition x:Name="ContentColumnZero"
                                        Width="Auto"&gt;&lt;/ColumnDefinition&gt;
                      &lt;ColumnDefinition Width="Auto"&gt;&lt;/ColumnDefinition&gt;
                      &lt;ColumnDefinition Width="Auto"&gt;&lt;/ColumnDefinition&gt;
                  &lt;/Grid.ColumnDefinitions&gt;
                  &lt;Grid.RowDefinitions&gt;
                      &lt;RowDefinition x:Name="ContentRowZero"
                                     Height="*"&gt;&lt;/RowDefinition&gt;
                      &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
                      &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
                  &lt;/Grid.RowDefinitions&gt;
  
                  &lt;Grid Name="ContentBlockA"
                        Grid.Column="0"&gt;
                      &lt;!-- Content here --&gt;
                  &lt;/Grid&gt;
  
                  &lt;Grid Name="ContentBlockB"
                        Grid.Column="1"&gt;
                      &lt;!-- Content here --&gt;
                  &lt;/Grid&gt;
  
                  &lt;Grid Name="ContentBlockC"
                        Grid.Column="2"&gt;
                      &lt;!-- Content here --&gt;
                  &lt;/Grid&gt;
              &lt;/Grid&gt;
          &lt;/ScrollViewer&gt;
      &lt;/Grid&gt;
  &lt;/Page&gt;
  </code></pre>