绑定DataGridTextColumn标头 [英] Binding DataGridTextColumn header

查看:60
本文介绍了绑定DataGridTextColumn标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据我背后的代码中的变量数组动态更新/设置DataGridTextColumn标头.

我背后的代码中.

I want to dynamically update/set the DataGridTextColumn header based on variable array in my code behind.

In my code behind.

 

;  私有列表< int>年;
      公共列表< int>年份
       {
                      得到
                         {
               返回年份;
}
          设置
           {
               年=值;
               RaisePropertyChanged(年份");
}
       }



在我的xaml文件中,我有一个数据网格,我想在其中设置列上的标题
          < toolkit:DataGrid ItemsSource =" {绑定价格}" AutoGenerateColumns =假">
               < toolkit:DataGrid.Columns>
            &b < toolkit:DataGridTextColumn Binding =< {Binding Gloves}";>
           &bsp; ;        < toolkit:DataGridTextColumn.Header>
             nbsp; b         <标签内容="{绑定年份[0]}"/>
                ;        </toolkit:DataGridTextColumn.Header>
             b ; </toolkit:DataGridTextColumn>
              </toolkit:DataGrid.Columns>
            </toolkit:DataGrid>


似乎不起作用,标题为空(未显示任何内容)
-如果我更改Content =" {Binding Years [0]}"" to Content ="2010"然后标题显示2010

有什么建议吗?提前thx

推荐答案

MrCoderMan,

-><标签内容=" {绑定年[0]}"/>

您是否尝试过在上面的绑定中应用值转换器而不设置绑定路径?因此,在后面的代码中,您可以在Convert方法中检查value参数.如果您仍然无法解决问题,我会看一下并对其进行修复.

谢谢.
此致.
Hi  MrCoderMan,

--><Label Content="{Binding Years[0]}"/>

Have you tried applying a value converter in the binding above without setting binding path? So in the code behind, you can check the value parameter in the Convert method. If you still can not figure it out, I will see to this and repro it.

Thanks.
Sincerely.


这篇关于绑定DataGridTextColumn标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆