XceedGrid。如何使与其他列相关的单元格可编辑(只读)
我有布尔属性 SpecValue,表明可以修改其他属性。
我找不到好的解决方案如何做到这一点。
我使用下一个解决方案,但存在一些错误。
<xcdg:Column Title="Value" FieldName="Value" Width="100" MaxWidth="100" MinWidth="100">
<xcdg:Column.CellEditor>
<xcdg:CellEditor>
<xcdg:CellEditor.EditTemplate>
<DataTemplate>
<TextBox x:Name="txtSpecVal" Text="{xcdgg:CellEditorBinding}" IsReadOnly="False"/>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type xcdg:Row}},Path=DataContext.SpecificValue}" Value="False">
<Setter TargetName="txtSpecVal" Property="IsReadOnly" Value="True"/>
<Setter TargetName="txtSpecVal" Property="BorderBrush" Value="Transparent"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</xcdg:CellEditor.EditTemplate>
</xcdg:CellEditor>
</xcdg:Column.CellEditor>
I have boolean Property SpecValue what indicates that other property can be modified.
I can't find good solution how to do it.
I use next solution, but there is some bugs.
<xcdg:Column Title="Value" FieldName="Value" Width="100" MaxWidth="100" MinWidth="100">
<xcdg:Column.CellEditor>
<xcdg:CellEditor>
<xcdg:CellEditor.EditTemplate>
<DataTemplate>
<TextBox x:Name="txtSpecVal" Text="{xcdgg:CellEditorBinding}" IsReadOnly="False"/>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type xcdg:Row}},Path=DataContext.SpecificValue}" Value="False">
<Setter TargetName="txtSpecVal" Property="IsReadOnly" Value="True"/>
<Setter TargetName="txtSpecVal" Property="BorderBrush" Value="Transparent"/>
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</xcdg:CellEditor.EditTemplate>
</xcdg:CellEditor>
</xcdg:Column.CellEditor>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这应该可行,这是一个以 DataCell 为目标的样式示例,只要“SpecificValue”单元格自身的值为 false,它就将其启用属性设置为 false。它应该可以帮助您入门。
您还可以参考以下博客文章以获取类似的详细示例:
http://xceed.com /CS/blogs/techside/archive/2011/07/06/datacell-styling-vs-cellcontenttemplate.aspx
This should work, This is an example of a style that targets DataCell and sets the "SpecificValue" cell's enabled property to false whenever it's own value is false. It should help you get started.
You can also refer to the following blog post for a similar detailed example:
http://xceed.com/CS/blogs/techside/archive/2011/07/06/datacell-styling-vs-cellcontenttemplate.aspx