Brian E
Brian E

Reputation: 67

Delete named row in WPF C#

I have a named textblock row within a named data grid that I would like to delete. Given that I know the name of the grid and the row, how do I delete the textblock? I expected to find something like:

row_01.Delete();

But no such luck. Here is the XAML:

<Grid Name="grid_01">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="10" />
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="10" />
    </Grid.ColumnDefinitions>

    <Grid.RowDefinitions>
        <RowDefinition Name="row_01" Height="10"/>
        <RowDefinition Name="row_02" Height="*" />
    </Grid.RowDefinitions>
    <Border BorderThickness="5" BorderBrush="Black" Grid.Row="1" Grid.Column="1">
        <TextBlock Grid.Column="1" Grid.Row="1"  Name="Tag_ContinueAs"  Text="Continue as Bejay" HorizontalAlignment="Center" />
    </Border>  

Upvotes: 1

Views: 91

Answers (2)

Matt L.
Matt L.

Reputation: 768

IN order to delete a Row, use:

grid_01.RowDefinitions.Remove(row_01);

Upvotes: 2

Noam M
Noam M

Reputation: 3164

One can use RemoveAt of RowDefinitions by index in order to remove a row, example:

grid_01.RowDefinitions.RemoveAt(INDEX);

Upvotes: 1

Related Questions