【发布时间】:2013-01-30 14:04:26
【问题描述】:
我需要根据属性在 datagridCell 上设置 IsReadOnly 属性。
<WPFCtrlDG:ExtDataGrid Grid.Row="2"
InternalAddCommandHandling="False"
InternalDeleteCommandsHandling="False"
ItemsSource="{Binding Path=Attributes, Mode=TwoWay}"
Command="{Binding Path=AttributesCommand}">
<WPFCtrlDG:ExtDataGrid.Columns>
<WPFCtrlDG:ExtDataGridTextColumn Header="Attribute" Tag="ID_ATTRIBUTE" Width="*" IsReadOnly="{Binding Path=FL_COMMON, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"/>
<WPFCtrlDG:ExtDataGridTextColumn Header="Value" Tag="ID_VALUE" Width="*" IsReadOnly="true"/>
</WPFCtrlDG:ExtDataGrid.Columns>
</WPFCtrlDG:ExtDataGrid>
public BindingList<SPC_SPL2_ATTRIBUTE> Attributes
{
get
{
if (Context.SPC_SPL2_ATTRIBUTE == null)
Controller.Execute(delegate(IResult result)
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("FL_ACTIVE", true);
parameters.Add("CD_SPL2", CurrentSPL2.CD_SPL2);
Model.Invalidate(typeof(SPC_SPL2_ATTRIBUTE), Filter.GENERIC<SPC_SPL2_ATTRIBUTE>(parameters, "ID_ATTRIBUTE"));
if (Model.Appendload(result) == false)
return false;
return result.Successful;
});
return Context.SPC_SPL2_ATTRIBUTE;
}
set { Context.SPC_SPL2_ATTRIBUTE = value; }
}
FL_COMMON 是一个布尔属性,位于数据网格中显示的对象内,但我编写的代码不起作用,而如果我将 IsreadOnly 设置为 true,它会起作用。
我做错了什么? 谢谢
【问题讨论】:
-
你能分享你绑定到 ItemSource 的类的结构吗?
-
添加,它是一个从数据库加载的bindingList
-
FL_COMMON与Attributes属性相比在哪里?它应该是Attributes集合内项目的属性。
标签: wpf datagrid readonly-attribute