I've got a TreeView binding to a hierarchical collection of different types of objects. The template for each type is selected using a "standard" TemplateSelector and all of these templates are using the same ContainerBindings to set the OptionType, depending on the type of object (some should have check boxes, some OptionType.None).
Now I also have a toggle button that enables/disables IsOptionElementsEnabled, but here's where things go wrong.
If I set the toggle button to be checked when the elements load, it all works as it should, but when I toggle the button on/off, the OptionType is all forgotten for the TreeViewItems and the checkboxes show next to all the items (which it shouldn't).
So what happends when toggling IsOptionElementsEnabled on the TreeView and how can I make the TreeViewItem.OptionType stick (or make it re-do the binding)?
ContainerBindings
Converter
ToggleButton & TreeView
Edit: using v.2011.1.419.1040 (the latest version that I have access to)
Best regards
Tobias
Now I also have a toggle button that enables/disables IsOptionElementsEnabled, but here's where things go wrong.
If I set the toggle button to be checked when the elements load, it all works as it should, but when I toggle the button on/off, the OptionType is all forgotten for the TreeViewItems and the checkboxes show next to all the items (which it shouldn't).
So what happends when toggling IsOptionElementsEnabled on the TreeView and how can I make the TreeViewItem.OptionType stick (or make it re-do the binding)?
ContainerBindings
<
telerik:ContainerBindingCollection
x:Name
=
"BindingsCollection"
>
<
telerik:ContainerBinding
PropertyName
=
"OptionType"
Binding
=
"{Binding Type, Converter={StaticResource TVITypeToOptionTypeConverter}, Mode=OneWay}"
/>
<
telerik:ContainerBinding
PropertyName
=
"IsSelected"
Binding
=
"{Binding IsSelected, Mode=TwoWay}"
/>
<
telerik:ContainerBinding
PropertyName
=
"IsExpanded"
Binding
=
"{Binding IsExpanded, Mode=TwoWay}"
/>
<
telerik:ContainerBinding
PropertyName
=
"IsEnabled"
Binding
=
"{Binding IsEnabled, Mode=TwoWay}"
/>
</
telerik:ContainerBindingCollection
>
Converter
public
class
TVITypeToOptionTypeConverter : IValueConverter
{
public
object
Convert(
object
value, Type targetType,
object
parameter, CultureInfo culture)
{
if
(value
is
Enumerators.TVIType)
{
switch
((Enumerators.TVIType) value)
{
case
Enumerators.TVIType.Building:
case
Enumerators.TVIType.Location:
case
Enumerators.TVIType.TreeStructureItem:
return
OptionListType.CheckList;
default
:
return
OptionListType.None;
}
}
return
null
;
}
public
object
ConvertBack(
object
value, Type targetType,
object
parameter, CultureInfo culture)
{
return
null
;
}
}
ToggleButton & TreeView
.....
<
telerik:RadToggleButton
x:Name
=
"ComparisonToggle"
Background
=
"Transparent"
BorderThickness
=
"0"
Height
=
"16"
Width
=
"16"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Center"
>
<
Image
Source
=
"/XXX.Infrastructure;Component/Resources/Images/scale.png"
/>
</
telerik:RadToggleButton
>
.....
<
telerik:RadTreeView
x:Name
=
"treeView"
IsEnabled
=
"{Binding CurrentlyFetchingData, Converter={StaticResource BooleanReverseConverter}}"
VerticalAlignment
=
"Stretch"
HorizontalAlignment
=
"Stretch"
ExpanderStyle
=
"{StaticResource ExpanderStyle}"
ItemsSource
=
"{Binding TreeViewItems, Mode=OneWay}"
SelectedItem
=
"{Binding SelectedTVI, Mode=TwoWay}"
ItemTemplateSelector
=
"{StaticResource TemplateSelector}"
IsOptionElementsEnabled
=
"{Binding ElementName=ComparisonToggle, Path=IsChecked}"
>
.....
</
telerik:RadTreeView
>
Edit: using v.2011.1.419.1040 (the latest version that I have access to)
Best regards
Tobias