Wpf datagrid列标题

时间:2013-03-03 11:36:41

标签: c# wpf data-binding

我需要将以下代码应用于每个DataGridTextColumn:

<DataGridTextColumn.HeaderTemplate>
    <DataTemplate>
        <StackPanel Orientation="Vertical">
            <TextBlock
                Text="{Binding Content, RelativeSource=
                     {RelativeSource Mode=TemplatedParent}}"
                Margin="5" />

            <Border DockPanel.Dock="Top"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center"
                    BorderBrush="Azure">

                <TextBox Width="Auto"
                         Text="{Binding SearchEngineCompassLogView.SearchText, 
                Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                         DataContext="{StaticResource CompassLogView}" />

            </Border>
        </StackPanel>
    </DataTemplate>
</DataGridTextColumn.HeaderTemplate>

问题是每个TextBox都需要一个特定的绑定,具体取决于DataGridTextColumn(在这种情况下,绑定是SearchEngineCompassLogView.SearchText

有什么建议我可以解决这个问题吗?

0 个答案:

没有答案