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; } }
Hello,
I have modified the sample I sent you before, so now it works as you want. Basically I set the NodeStyle of the ChildLayout, too. Also I can say that the visibility of the CheckBoxes is determined by the IsAvailable property in the ViewModel.
Hope this helps you.
Hi Stoyanov,
Still I am facing the same problem, the parent checkbox is not getting Hide if all the child Node's check box are Hide. And i want to do this using MVVM.
Thanks for your response. and waiting for the solution of this problem.
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
I have modified the sample Petar has sent you, so now it works as you want. You need to set the IsAvailable Property to all Items in the DataSource, so the binding that determines the visibility of the CheckBox could work correctly. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.