tags:

views:

217

answers:

0

Ive created templated column in DataGrid with textbox in header template for grid filtering. Is it possible to make dynamic resize of textbox, so that textbox was 100% width of columns width?

<my:DataGrid AutoGenerateColumns="False" Name="dgEmployees" IsReadOnly="True" Background="DarkGray" GridLinesVisibility="All" SelectionChanged="dgEmployees_SelectionChanged" Margin="0,29,0,0">
        <my:DataGrid.Columns>
            <my:DataGridTemplateColumn Width="auto">
                <my:DataGridTemplateColumn.HeaderTemplate>
                    <DataTemplate>
                        <Grid HorizontalAlignment="Stretch">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20"/>
                                <RowDefinition Height="auto"/>
                            </Grid.RowDefinitions>
                            <TextBlock Text="Фамилия"/>
                            <Border CornerRadius="5" BorderBrush="White" BorderThickness="2" Grid.Row="1" Background="Black" HorizontalAlignment="Stretch" MinWidth="200" Margin="0,0,0,0">
                                <TextBox x:Name="tbFilter" KeyDown="TextBox_KeyDown" BorderBrush="Transparent" Foreground="White" Background="Transparent" Margin="3,0,3,0"/>
                            </Border>
                        </Grid>
                    </DataTemplate>
                </my:DataGridTemplateColumn.HeaderTemplate>
                <my:DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Path=FName, Mode=OneWay}"/>
                    </DataTemplate>
                </my:DataGridTemplateColumn.CellTemplate>
            </my:DataGridTemplateColumn>
        </my:DataGrid.Columns>
    </my:DataGrid>