0
如何在datagrid中訪問控件ColumnHeaderStyle?如何在datagrid ColumnHeaderStyle中訪問控件?
此示例中:
<Style x:Key="DataGridColumnHeaderStyle1" TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
<Grid Name="grdPeresenter" VerticalAlignment="Center" HorizontalAlignment="Stretch">
<TextBox x:Name="txtSearch" Grid.Row="1" BorderThickness="2" PreviewMouseLeftButtonUp="grid1_PreviewMouseLeftButtonUp" HorizontalAlignment="Stretch" TextChanged="TextBox_TextChanged" >
</TextBox>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
和
<DataGrid x:Name="grd" ItemsSource="{Binding Source={StaticResource theSource}}" AutoGenerateColumns="False"
ColumnHeaderStyle="{DynamicResource DataGridColumnHeaderStyle1}" PreviewKeyDown="grd_PreviewKeyDown"
SelectedIndex="{Binding SelectedIndex}"
SelectedItem="{Binding SelectedItem}"
behavior:MouseDoubleClick.Command="{Binding MouseDoubleClickCommand}"
GridLinesVisibility="Vertical">
</DataGrid>
我想例如訪問TEXTSEARCH datagrid.is的第一列的可能是如何?