Note that there are some explanatory texts on larger screens.

plurals
  1. POSrange result about wpf grid row removal
    text
    copied!<p>I have a question about grid removal:</p> <p>whenever I delete the last row or all rows in the grid, there is still something(actually the last row) displayed on the grid. I did actually checked the grid.rowdefinitions.count is 0. the method I used is removeAt and removeRange(0, grid.rowdefinitions.count). what's wrong with that? Can anybody tell why? Many thanks!</p> <pre><code>//------------ &lt;Grid DockPanel.Dock="Top" HorizontalAlignment="Left" Name="grid1" ShowGridLines="true" Width="200" Height="200"&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition/&gt; &lt;ColumnDefinition/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition/&gt; &lt;RowDefinition/&gt; &lt;RowDefinition/&gt; &lt;RowDefinition/&gt; &lt;RowDefinition/&gt; &lt;/Grid.RowDefinitions&gt; &lt;TextBlock Grid.Row="0" Grid.Column="0" Text="100" /&gt; &lt;TextBlock Grid.Row="1" Grid.Column="0" Text="200" /&gt; &lt;TextBlock Grid.Row="2" Grid.Column="0" Text="300" /&gt; &lt;TextBlock Grid.Row="3" Grid.Column="0" Text="400" /&gt; &lt;TextBlock Grid.Row="4" Grid.Column="0" Text="500" /&gt; &lt;/Grid&gt; &lt;StackPanel HorizontalAlignment="Left" Orientation="Horizontal" Width="200" DockPanel.Dock="Top"&gt; &lt;Button Width="80" Click="rem5Row"&gt;Remove 5 Rows&lt;/Button&gt; &lt;/StackPanel&gt; //-------------- private void rem5Row(object sender, RoutedEventArgs e) { if (grid1.RowDefinitions.Count &lt; 5) { Console.WriteLine("less than 5!"); } else { grid1.RowDefinitions.RemoveRange(0,grid1.RowDefinitions.Count); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload