Default style fore Null Value is grey check in XamCheckEditor. How can I change it to show null value as unchecked(false value)?
When XamCheckEditor value is True and IsReadOnly=True, it appears exactly the same way as Null Value(grey check), which is very confusing. How can I change it to Grey background with Black Check instead?
Hello,
I have been investigating into your issue and I do understand your concern. In order to achieve the desired behavior could re-template the xamCheckEditors default template, by placing the new modified ControlTemplate in a style. This style will be triggered when the Value property becomes Null. Since the default template is using a ValueEditorCheckBox, we can bind the IsChecked property of that control to the corresponding parents property including one important feature– we can put a value converter in order to catch the null value and return false. With that custom technique the controls Value property will remains Null, but the inner ValueEditorCheckBox would not be checked. That means the xamCheckEditor will never show the blue square that marks the Indeterminate state.
Here is a corresponding sample:
Xaml part
<local:TriggersConverter x:Key="someRes"/>
<Style TargetType="{x:Type igEditors:XamCheckEditor}">
<Style.Triggers>
<Trigger Property="Value" Value="{x:Null}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igEditors:XamCheckEditor}">
<Border x:Name="MainBorder"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}">
<!-- SSP 10/3/07 BR25672 Added Padding="{TemplateBinding Padding}" to the ValueEditorCheckBox below -->
<igEditors:ValueEditorCheckBox x:Name="PART_FocusSite"
IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource kkk}, Path=IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsThreeState="{TemplateBinding IsThreeState}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Margin="{TemplateBinding Padding}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
Code behind part:
public class TriggersConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
if (value == null)
return false;
}
return true;
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
return value;
In case of other concerns on that matter please do not hesitate to ask.
Sincerely,
Ekaterina
Developer Support Engineer
Infragistics Inc.
www.infragistics.com/support
The style and converter look good. I tried to put a trigger when ischecked = null. Did not work. I will try yours. Thanks!
Why do I see different stlye as you do? how can I see the rectangular shade as you when it is null?
It's related to Desktop Theme.
If I use window classic. I see what I saw. If I switch to windows XP, I can see what you see. Too bad our users mostly use windows classic theme.
I have been looking into your issue and I have modified my sample, so it meets you requirements. I added one additional multiconverter whose purpose is to check IsEnabled and IsReadOnly properties states and apply them on the new style.
I am attaching a sample project that will demonstrate the mentioned behavior. I have added couple of buttons that set different states to the xamCheckEditor programmatically, and also a textbox that monitors the controls Value property. In addition to that I have added one editor with its IsReadOnly property set to true and one with a default behavior without any additional modifications, just for demonstrational purpose.
In case of additional problems on this matter please do not hesitate to ask.