Welcome to the Xceed Community | Help
Community Search  
More Search Options

Cell Disabling using DataTriggers

Sort Posts: Previous Next
  •  07-02-2009, 4:42 AM Post no. 22205

    Cell Disabling using DataTriggers

    Hi,

    I am using Xceed DataGrid for WPF binding it with an observable collection. I have around 20 columns and i am looking to set the individual cell (not whole column) enable/disable as per my business logic.

    I tried setting the same from corresponding .xaml.cs file using:

    "((DataRow)dataGrid.GetContainerFromItem(anItem)).Cells[someCell].IsEnabled = false;"

    However the setting is not preserved after scrolling or some other rendering. To solve this I decided to go with DataTrigger. Currently i am using one extra property per original property in my class. For example, if there is a column "Name" i am keeping one extra property as "Name_Enabled" to keep the enable/disable information of "Name" property. I am using this "Name_Enabled" property in data trigger to set the "IsEnabled" property of "Name" accordingly. So now i am having 40 columns instead of 20 :(

    Is there any better way to acheive this?

    Please help!

  •  07-03-2009, 12:59 PM Post no. 22260 in reply to 22205

    Re: Cell Disabling using DataTriggers

    Hi,

    The ideal method is to use an implicit Style on DataCell with a DataTrigger in which you can set the “IsEnabled” property.

    For example:

    <Style TargetType="xcdg:DataCell">

                    <Style.Triggers>

                        <DataTrigger Binding="{Binding Path=DataContext[Name_Enabled],RelativeSource={RelativeSource Self}}"

                                     Value="True">

                            <Setter Property="IsEnabled"

                                    Value="True" />

                        </DataTrigger>            

                    </Style.Triggers>

                </Style>

     


    Xceed - Software Developer and Technical Support
  •  02-17-2010, 4:26 AM Post no. 25819 in reply to 22260

    Re: Cell Disabling using DataTriggers

    same case here:

    I would have thought that below should have worked

    "((DataRow)dataGrid.GetContainerFromItem(anItem)).Cells[someCell].IsEnabled = false;"

    However the setting is not preserved after scrolling or some other rendering.

     

    can any body suggest on what is going wrong here and any workaround.

     

     

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.