Hi,
I created a little UI that allow user to personalize the GridView properties.
I a section of this UI, a user can add a "Format Condition" defining an Expression (using RedExpressions) and some Style preferences, in example a row background.
When a FormatCondition class is created, in the constructor, I add a StyleRule to GridView.RowStyleSelector, I bind the StyleRuleCondition to FormatCondition.Condition and I'm waiting for BackGround changes:
Grid = g;
Css = (ConditionalStyleSelector)(g.RowStyleSelector ?? (g.RowStyleSelector = new ConditionalStyleSelector()));
StyleRule = new StyleRule();
StyleRule.Bind(StyleRule.ConditionProperty, Condition, converter: new Converters.FunctionConverter<string, System.Linq.Expressions.Expression>(Convert));
StyleRule.Style = new System.Windows.Style(typeof(GridViewRow)
, (Style)Application.Current.FindResource("GridViewRowStyle"));
Css.Rules.Add(StyleRule);
BackGroundColor.ValueChanged += (p) => ResetBg();
If BackGround change I edit the Background setter:
if (BgSetter != null) Style.Setters.Remove(BgSetter);
BgSetter = null;
if (!BackGroundColor.Value.HasValue) return;
BgSetter = new Setter(GridViewRow.BackgroundProperty, new SolidColorBrush(BackGroundColor.Value.Value));
Style.Setters.Add(BgSetter);
I think this is logically correct but Grid Style don't change until a rows refresh occours.
How I can force grid to re-evaluate row stryle rules?
marc.