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

Set background on datarow

Sort Posts: Previous Next
  •  11-20-2009, 6:40 AM Post no. 24930

    Set background on datarow

    Hello, i have a problem with datagrid 

    I need to set background color for DataRow immediately after the DataRow has been created and before DataRows is showed in grid

    Has anyone any ideas?

    Thanks for help


    Filed under: ,
  •  11-20-2009, 8:19 AM Post no. 24931 in reply to 24930

    Re: Set background on datarow

    The easiest way is to assign a style that targets DataRow, and in that set the Background to whatever colour you want. If it is data dependent then I suggest using a Converter to achieve the desired result.

    <Style TargetType="{x:Type xcdg:DataRow}">

    <Setter Property="Background" Value="AliceBlue"/>

    </Style>

  •  11-20-2009, 8:29 AM Post no. 24932 in reply to 24931

    Re: Set background on datarow

    Thanks,

    but I need to set Background Property in code behind as a result of some condition

  •  11-25-2009, 12:47 PM Post no. 24996 in reply to 24932

    Re: Set background on datarow

    Derek's answer is right. This is the best way to go. For different condition, you should use DataTriggers in the style. 

    This is the way to go because the DataGridControl does Container Recycling which will reuse an instance of DataRow to display other business object. You don't want to explicitly set the value on DataRows or DataCells sinc they will be permanent and you'll get weird behavior in your grid. 


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