Hi,
I am working on xamDataTree and facing a problem, I want to set the Checkbox Visibility of the inner Nodes based on a condition (i.e. if the EntityInformation.CheckBoxEnable property is "false" then I dont want to display the checkbox).
But when I am trying to do like
<ig:CheckBoxSettingsOverride CheckBoxVisibility="{Binding Data.EntityInformation.CheckBoxEnable, Converter={StaticResource boolToVisibilityConverter}}"/>
I am getting following error
A 'Binding' cannot be set on the 'CheckBoxVisibility' property of type 'CheckBoxSettingsOverride'. A 'Binding' can only be set on a DependencyProperty of a DependencyObject.
Please help me to acheive the functionality.
I encountered the same issue. However, I do not like to write every style and events from scratch as suggested in the answer. Instead the workaround which I found is to bind Width property of check box instead using ig:CheckBoxSettings.CheckBoxStyle. Note that binding the Visibility property won't work.
<UserControl.Resources> <helpers:BoolToCheckBoxWidthConverter x:Uid="BoolToCheckBoxWidthConverter" x:Key="BoolToWidthConverter"/> </UserControl.Resources>
.
<ig:XamDataTree.CheckBoxSettings> <ig:CheckBoxSettings x:Uid="CheckBoxSettings" CheckBoxMode="Auto" CheckBoxVisibility="Visible"> <ig:CheckBoxSettings.CheckBoxStyle> <Style x:Uid="TreeViewItemStyless" TargetType="{x:Type CheckBox}"> <Setter x:Uid="IsEnabledSetter" Property="IsEnabled" Value="{Binding Data.IsCheckBoxEnabled}"/> <Setter x:Uid="WidthSetter" Property="Width" Value="{Binding Data.IsCheckBoxVisible, Converter={StaticResource BoolToWidthConverter}}"/> </Style> </ig:CheckBoxSettings.CheckBoxStyle> </ig:CheckBoxSettings> </ig:XamDataTree.CheckBoxSettings>
internal class BoolToCheckBoxWidthConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { // 20 is the default for the check box return 20; }
var bValue = (bool)value;
return bValue ? 20 : 0; }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { var iValue = (int?)value;
return iValue != 0; } }