I have a textbox and a button in my columnheader. The textbox should be collapsed until i press the button. The problem is i can't access the textbox programmaticly.
I tried tbTest.Visibility = Visibility.Visible;
but it shows the following error:
"The name 'tbTest' does not exist in the current context"
I also need tbTest.Text
and it doesnt work.
Here's my code:
<DataGridTextColumn.HeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="DataGridColumnHeader">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="auto"></ColumnDefinition>
<ColumnDefinition Width="auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<ContentPresenter />
<Label Grid.Column="0" Padding="5 0" Content="Gruppe" VerticalAlignment="Center" Cursor="Hand" Foreground="White"/>
<TextBox x:Name="tbTest" Grid.Column="1" Width="150" Visibility="Collapsed" TextChanged="tbTest_TextChanged"></TextBox>
<Button Grid.Column="2" x:Name="btnFilterGroup" Style="{StaticResource MyButton}" Width="16" Height="16" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0 0 10 0" Click="btnFilterGroup_Click">
<Button.Background>
<ImageBrush ImageSource="Resources/filter.png"/>
</Button.Background>
</Button>
<Thumb x:Name="PART_RightHeaderGripper" Grid.Column="3" HorizontalAlignment="Right" Width="2" BorderThickness="0.6"
BorderBrush="{Binding VerticalGridLinesBrush, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}" Cursor="SizeWE"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DataGridTextColumn.HeaderStyle>