lundi 12 mai 2014

Set the visibility of a large set of rows with one surrounding control


Vote count:

0




Is it possible to surround a large set of rows in a Grid with a control so that I don't have to set the visibility for every control in those rows?


Example


Let's say I have the following grid:



<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="150" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
</Grid>


Every row has the following controls in it:



<TextBlock Grid.Column="0"
Grid.Row="[rowNumber]"
Text="LabelText" />
<TextBox Grid.Column="1"
Grid.Row="[rowNumber]"
Text="{Binding TextBinding}" />


Is it possible to surround, let's say, row 2-8, with a control where I can set the Visibility on, so that I don't have to set the Visibility for every control in row 2-8. This control isn't a child object of the Grid (when it is, the lay-out structure isn't correct, or at least not when I tried it...).



<Grid>
/** Row and column definitions **/

/** Items from row 0 and 1 **/

<SurroundingElement Visibility="Collapsed">
/** Items from row 2 - 8 **/
</SurroundingElement>

/** Items from row 9 **/
</Grid>


I know it is possible with adding an inner Grid in this Grid, where the inner Grid contains the rows and items of row 2-8, and setting the Visibility of the inner Grid. But I am curious if there is another way.


Thanks in advance!


Loetn



asked 35 secs ago

Loetn

1,108





Aucun commentaire:

Enregistrer un commentaire