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

Binding ReadOnly Property of a Column

Sort Posts: Previous Next
  •  08-12-2010, 5:48 AM Post no. 27955

    Binding ReadOnly Property of a Column

    Hi,

    Is there a way to bind the readonly property of a column depending on a property value of the underlying dataobject?

    eg:

    the dataobject has the properties category A and category B. If category A has a certain value, let's say 1, the user is allowed to edit category B in the grid. Therefore the dataobject has a bool property called "has_category_A_value_1" which returns true if A equals 1:

    <sldg:column FieldName="categoryA"/>

    <sldg:column FieldName="categoryB" ReadOnly="{Binding has_category_A_value_1" />

     if this kind of binding is not possible, is it possible to somehow tell the ActivatingCellEditor function not to show up the editcontrol?

    thanks

  •  08-12-2010, 1:52 PM Post no. 27959 in reply to 27955

    Re: Binding ReadOnly Property of a Column

    Hi Juerg,

      A binding set this way would not have the intended behavior.

      My suggestion would be to subclass DataCell, override the ReadOnly property and return "True" for matching condition.
      
      In order for the subclassed DataCell to be used by the DataGridControl, you'll need to sublcass DataRow ( override CreateCell() ) and DataGridControl (override CreateContainerForItem() ).

      This would do the trick if the condition nevers changes (hardcoded property/fieldname). With some additional work, this approach can be extended to be extensible by creating an attached property to specify property name, then set the attached property on Column (and access said property dynamically by reflection at Cell initialization).


     


    Marc Laroche
    Software Developer
    Xceed Software Inc.


    I don’t suffer from insanity, I enjoy every minute of it. - Unknown
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.