达网络v4的DataGridTextColumn.IsReadOnly似乎是有故障

编程入门 行业动态 更新时间:2024-10-23 07:37:24
本文介绍了达网络v4的DataGridTextColumn.IsReadOnly似乎是有故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如果我创建一个绑定的 DataGridTextColumn ,它不actualize的的IsReadOnly 属性。如果我通过标记设置它,它的工作原理。

If I create a binding to the IsReadOnly property of the DataGridTextColumn, it does not actualize. If I set it through markup, it works.

<DataGridTextColumn IsReadOnly="{Binding IsReferenceInactive}"/> <!-- NOP --> <DataGridTextColumn IsReadOnly="True"/> <!-- Works as expected, cell is r/o -->

在 IsReferenceInactive 属性是一个DP和工作正常(出于测试目的,我将它绑定到一个复选框,该工作)

The IsReferenceInactive property is a DP and works fine (For testing purposes I've bound it to a checkbox, that worked)

这是一个已知的限制?

更新

UUPS,其他比我写的,有在输出窗口消息:

Uups, other than I wrote, there is a message in the output window:

System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=IsReferenceInactive; DataItem=null; target element is 'DataGridTextColumn' (HashCode=23836176); target property is 'IsReadOnly' (type 'Boolean')

好像是这样:

Seems to be this one:

connect.microsoft/VisualStudio/feedback/details/530280/wpf-4-vs2010-datagrid-isreadonly-does-not-work-with-binding-to-boolean-property

推荐答案

的DataGridColumn 是不是可视化树的一部分,不参加这样的结合。我周围的获得方法是使用 DataGridTemplateColumn 。

DataGridColumns are not part of the visual tree, and don't participate in binding like this. The way I get around it is to use DataGridTemplateColumn.

<DataGridTemplateColumn> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=myProperty}" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellEditingTemplate> <DataTemplate> <TextBox IsEnabled="{Binding Path=myBool}" Text="{Binding Path=myProperty Mode=TwoWay}" /> </DataTemplate> </DataGridTemplateColumn.CellEditingTemplate> </DataGridTemplateColumn>

有其他的处理方法是,我发现有点太hackish的,但他们做的工作;即:blogs.msdn/b/jaimer/archive/2008/11/22/forwarding-the-datagrid-s-datacontext-to-its-columns.aspx

There are other workarounds, which I've found a bit too hackish, but they do work; to wit: blogs.msdn/b/jaimer/archive/2008/11/22/forwarding-the-datagrid-s-datacontext-to-its-columns.aspx

更多推荐

达网络v4的DataGridTextColumn.IsReadOnly似乎是有故障

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

发布评论

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

>www.elefans.com

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