Hi,
I am binding a treeview to a collection of objects. This is for use in a user/group permissions for my application.
The treeview is displaying up to four levels
The tree binds to a property on the object of type bool? , to achieve the tri state.
This is the ItemContainerStyle for the treeview
The value converter;
The binding to the tree works perfectly, the problem I am having is when an treeviewitem is in the indeterminate state on the tree view.
When an item has been put in the indeteminate state, the (ToggleState)value in the ConvertBack method is set to 'Off', I would have expected this to be set to 'Indeterminate'.
I know the ConvertBack method doesn't actually deal with the indeterminate state, but that is due to me not being able to get it.
Is there something I am doing wrong?
Thanks,
A Marshall
I am binding a treeview to a collection of objects. This is for use in a user/group permissions for my application.
The treeview is displaying up to four levels
The tree binds to a property on the object of type bool? , to achieve the tri state.
This is the ItemContainerStyle for the treeview
<Style x:Key="GroupSecurityRadTreeStyle" TargetType="telerik:RadTreeViewItem"> |
<Setter Property="CheckState" Value="{Binding IsGroupActivated,Mode=TwoWay, Converter={StaticResource CheckStateConverter}}"/> |
<Setter Property="IsExpanded" Value="True"/> |
</Style> |
The value converter;
public class CheckStateConverter : IValueConverter |
{ |
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
{ |
bool? result = (bool?)value; |
if (result.HasValue) |
{ |
return result.Value ? ToggleState.On : ToggleState.Off; |
} |
else |
{ |
ToggleState o = ToggleState.Indeterminate; |
return o; |
} |
} |
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) |
{ |
ToggleState state = (ToggleState)value; |
return state == ToggleState.On ? true : false; |
} |
} |
The binding to the tree works perfectly, the problem I am having is when an treeviewitem is in the indeterminate state on the tree view.
When an item has been put in the indeteminate state, the (ToggleState)value in the ConvertBack method is set to 'Off', I would have expected this to be set to 'Indeterminate'.
I know the ConvertBack method doesn't actually deal with the indeterminate state, but that is due to me not being able to get it.
Is there something I am doing wrong?
Thanks,
A Marshall