This question is locked. New answers and comments are not allowed.
This is a simplified version of my class
public
class
Item
{
int
_id;
string _name;
Item _parentItem;
ObservableCollection<Item> _childItems;
}
The thing I want to do is to have them in a treeview acording to their relationship. And this is how I did it.
<
telerikNavigation:RadTreeView
ItemsSource
=
"{Binding TreeItems,Converter={StaticResource HierarchyConverter}}"
ItemTemplate
=
"{StaticResource TreeTemplate}"
/>
<
converter:HierarchyConverter
x:Name
=
"HierarchyConverter"
/>
<
telerik:HierarchicalDataTemplate
x:Key
=
"TreeTemplate"
ItemsSource
=
"{Binding Converter={StaticResource HierarchyConverter}}"
>
<
TextBlock
Text
=
"{Binding Name}"
/>
</
telerik:HierarchicalDataTemplate
>
And I also use this converter
public
class
HierarchyConverter : IValueConverter
{
public
object
Convert(
object
value, Type targetType,
object
parameter, CultureInfo culture)
{
// We are binding an item
TreeItem item = value
as
TreeItem;
if
(item !=
null
)
{
return
item.Children;
}
ObservableCollection<TreeItem> items = value
as
ObservableCollection<TreeItem>;
if
(items !=
null
)
{
return
items;
}
return
null
;
}
public
object
ConvertBack(
object
value, Type targetType,
object
parameter, CultureInfo culture)
{
throw
new
NotImplementedException();
}
}
I only get the first "level" and see the arrows next to the name but they won't expand so that I don't know if I did everything correct.
Any help?
Edit:
Added this code
<
telerik:ContainerBindingCollection
x:Key
=
"TreeViewItemContainerBinding"
>
<
telerik:ContainerBinding
PropertyName
=
"IsExpanded"
Binding
=
"{Binding Path=IsActive, Mode=TwoWay}"
/>
<
telerik:ContainerBinding
PropertyName
=
"IsSelected"
Binding
=
"{Binding Path=IsActive}"
/>
</
telerik:ContainerBindingCollection
>
But now everything is expanded and when I click on an item it doesnt look like it's selected... it is just "flashing"