【问题标题】:Binding current columns header as text for a text block inside datatemplate将当前列标题绑定为数据模板内文本块的文本
【发布时间】:2011-05-01 16:43:54
【问题描述】:

我正在使用 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}" ,但它不起作用。如何将列标题值绑定为文本块的文本

【问题讨论】:

    标签: silverlight datagridcolumn


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-02
      • 2013-09-14
      • 1970-01-01
      • 2010-12-12
      相关资源
      最近更新 更多