1

我正在使用 silverlightdatgrid,并且每个列标题都有如下样式

<Style x:Name="mytemplate" x:Key="mytemplate"  xmlns:dataprimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
                            TargetType="dataprimitives:DataGridColumnHeader">
            <Setter Property="ContentTemplate" >
                <Setter.Value>
                    <DataTemplate x:Name="ColHeaderTemplategrid">
                         <StackPanel>
                             <TextBlock Text="{Binding  this.Content}" ></TextBlock>
                             <TextBox x:Name="txtfilterBox"  KeyDown="txtfilterBox_KeyDown" Width="40"/>
                        </StackPanel>

                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>

现在的问题是如何将每个列标题值绑定为堆栈面板内文本块的文本。我只是尝试使用 Text="{Binding this.Content}" ,但它不起作用。如何将列标题值绑定为文本块的文本

4

1 回答 1

1

嗨,下面的代码整理出我的问题会将当前列标题绑定为文本块的文本

<DataTemplate x:Name="ColHeaderTemplategrid">
                         <StackPanel>
                             <TextBlock Text="{Binding}" ></TextBlock>
                             <TextBox x:Name="txtfilterBox"  KeyDown="txtfilterBox_KeyDown" Width="40"/>
                        </StackPanel>

                    </DataTemplate>
于 2010-10-28T05:20:05.437 回答