Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
120
Adding EqualToConditional to UnboundColumn to change the background
posted

Am programmatically adding an unboundColumn, adding a ValueConverter to it and adding a ConditionalFormatCollection by defining EqualToConditional to change the background of the cell depending on the cell value, It doesnt work.

Below is the code

Style s = new Style();s.TargetType = typeof(ConditionalFormattingCellControl);s.Setters.Add(new Setter(ConditionalFormattingCellControl.BackgroundProperty, new SolidColorBrushColors.Green)));

EqualToConditionalFormatRule

 

 

equalRule = new EqualToConditionalFormatRule();equalRule.Value = 1; equalRule.StyleToApply = s;equalRule.StyleScope = StyleScope.Cell;

 

 

UnboundColumn imgColumn = new UnboundColumn { Key = brkr.BrokerName + "Img" }; imgColumn.ValueConverter = new CommentTypeIconConverterX();imgColumn.ValueConverterParameter = brkr.BrokerName + "Img";imgColumn.HeaderText = " ";imgColumn.ConditionalFormatCollection.Add(equalRule);xamFileDetailsGrid.Columns.Add(imgColumn);

Parents
No Data
Reply
  • 34510
    Offline posted

    Hi doyouknowme,

    Conditional formatting rules check the underlying data object so in order to apply one to an UnboundColumn you can create a custom rule and perform logic on your data object that determines what style to apply to the current cell or null for no style.  I've attached a sample that demonstrates how you could do this.

    Let me know if you have any questions on this.

    xamGrid-UnboundColumnConFormatting.zip
Children