开发者

XceedGrid. How to make cell editable related to other column(readonly)

开发者 https://www.devze.com 2023-02-20 03:44 出处:网络
I have boolean Property SpecValue what indicates that other property can be modified. I can\'t find good solution how to do it.

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 FindAncesto开发者_JS百科r, 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>


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.

    <Style.Triggers >

        <MultiDataTrigger>

          <MultiDataTrigger.Conditions>

              <Condition Binding="{Binding RelativeSource={RelativeSource self}, 
                                                        Path=ParentColumn.FieldName}"
                          Value="SpecificValue"/>

              <Condition Binding="{Binding
                                                        RelativeSource={RelativeSource self}, 
                                                        Path=ParentRow.DataContext.SpecificValue}" 
                          Value="false"/>

          </MultiDataTrigger.Conditions>

          <Setter Property="Background" Value="Green" />
          <Setter Property="IsEnabled" Value="False" />
        </MultiDataTrigger>
    </Style.Triggers>
  </Style>

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号