Silverlight DataGridTextColumn绑定可见性

编程入门 行业动态 更新时间:2024-10-24 06:27:04
本文介绍了Silverlight DataGridTextColumn绑定可见性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在我的之前的帖子之后,我现在正在尝试绑定可见性的DataGridColumns到VM通知属性。 MSDN 建议我可以轻松地做到这一点。

我已经有一个值转换器和VM通知属性,我知道的作品(我有在我的页面上的另一个元素上测试了这些:

< CheckBox x:Name =chkAllTeamsVisibility ={Binding Converter = {StaticResource BoolToVisibilityConverter},Path = AllTeams}/>

此复选框控件的可见性反映为当我在DataTextColumn上设置相同的绑定时,我在XAML的 Visibility = 行上得到一个AG_E_BAD_PARSER错误:

code>< data:DataGridTextColumn Visibility ={Binding Converter = {StaticResource BoolToVisibilityConverter},Path = AllTeams} /> / pre>

任何想法任何人?感谢标记

解决方案

在DataGridTextColumn上的可见性是复选框中的不同的野兽。基本上,它不是依赖属性,不能是数据绑定的。如果您需要此功能,您可以继承DataGridTextColumn并添加您自己的依赖属性来获取行为。

  • 矩形从UIElement获取其Visibility属性并且是依赖属性
  • DataGridTextColumn从DataGridColumn获取其可见性,不是依赖属性。

Following my earlier post I am now trying now to bind the visibility of DataGridColumns to a VM notification property. MSDN suggests I should be able to do this with ease.

I already have a value convertor and VM notification property that I know works (I have tested these on another element on my page:

<CheckBox x:Name="chkAllTeams" Visibility="{Binding Converter={StaticResource BoolToVisibilityConverter}, Path=AllTeams}"/>

This checkbox control visibility reacts as I would expect. When I set the same binding on the DataTextColumn I get an AG_E_BAD_PARSER error on the Visibility= line of XAML:

<data:DataGridTextColumn Visibility="{Binding Converter={StaticResource BoolToVisibilityConverter}, Path=AllTeams}" />

Any ideas anyone? Thanks, Mark

解决方案

Visibility on the DataGridTextColumn is a different beast on the checkbox. Basically, it isn't a dependency property and can't be data-bound. If you need this functionality, you can subclass DataGridTextColumn and add your own dependency property to get the behavior.

  • Rectangle gets its Visibility property from UIElement and is a dependency property
  • DataGridTextColumn gets its Visibility from DataGridColumn and isn't a dependency property.

更多推荐

Silverlight DataGridTextColumn绑定可见性

本文发布于:2023-11-03 12:48:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555176.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:绑定   见性   Silverlight   DataGridTextColumn

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!