hi
i am using the following code to apply conditional formatting on selected columns.
it's always hiding the values of the cells (that meet the condition) .
i set the r.CellValueVisibility = System.Windows.Visibility.Visible; but the same problem.
ContainingConditionalFormatRule r = new ContainingConditionalFormatRule();
r.CellValueVisibility = System.Windows.Visibility.Visible;
r.StyleScope = StyleScope.Cell;
r.ShouldRefreshOnDataChange = true;
Style s = new Style(typeof(CellControl));
FontWeight fw = format.P_IsBold?FontWeights.Bold:FontWeights.Normal;
FontStyle fs = format.P_IsItalic?FontStyles.Italic:FontStyles.Normal;
s.Setters.Add(new Setter(FontFamilyProperty,format.P_FontName));
s.Setters.Add(new Setter(FontSizeProperty,format.P_FontSize));
s.Setters.Add(new Setter(BackgroundProperty,format.P_BackColor));
s.Setters.Add(new Setter(ForegroundProperty,format.P_ForeColor));
s.Setters.Add(new Setter(FontWeightProperty,fw));
s.Setters.Add(new Setter(FontStyleProperty,fs));
r.StyleToApply = s;
r.Value = "Ame";
foreach (Column col in XamMainGrid.SelectionSettings.SelectedColumns)
{
col.ConditionalFormatCollection.Add(r);
}
Thanks...
i didn't know about the ConditionalFormattingCellControl and dependencyProperties.
Hi,
Could you try the following snippet?
... private void Button_Click(object sender, RoutedEventArgs e) { foreach (Column col in XGrid.SelectionSettings.SelectedColumns) { col.ConditionalFormatCollection.Add(this.RuleFactory()); } } private ConditionalFormattingRuleBase RuleFactory() { ContainingConditionalFormatRule r = new ContainingConditionalFormatRule(); r.ShouldRefreshOnDataChange = true; Style s = new Style(typeof(ConditionalFormattingCellControl)); s.Setters.Add(new Setter(ConditionalFormattingCellControl.FontFamilyProperty, new FontFamily("MS UI Gothic"))); s.Setters.Add(new Setter(ConditionalFormattingCellControl.FontSizeProperty, 15.0)); s.Setters.Add(new Setter(ConditionalFormattingCellControl.BackgroundProperty, new SolidColorBrush(Colors.Red))); s.Setters.Add(new Setter(ConditionalFormattingCellControl.AltBackgroundProperty, new SolidColorBrush(Colors.Red))); s.Setters.Add(new Setter(ConditionalFormattingCellControl.ForegroundProperty, new SolidColorBrush(Colors.Yellow))); s.Setters.Add(new Setter(ConditionalFormattingCellControl.FontWeightProperty, FontWeights.Bold)); r.StyleToApply = s; r.Value = "Str"; return r; } ...
Note that a new rule is created for each column. The TargetType of the Style is ConditionalFormattingCellControl and the DependencyProperties used in the setters are the DPs of the ConditionalFormattingCellControl.
HTH
any suggestions?
i tried it.. still the same problem
No,
this is the first and only condition i added so far.. i am still in the beginning and just testing it.
i will try to set it as the terminal rule as well