Hello,
I would like to ask for your help. When creating RadTreeView my ItemContainerStyle is not working. I would like to connect ViewModel IsExpanded with RadTreeViewItem but I can't do it. The component works fine for me if I define a HierarchicalDataTemplate for the Item template as follows.
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
<Grid.Resources>
<HierarchicalDataTemplate x:Key="ItemTemplateTree"
ItemsSource="{Binding Children}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" FontWeight="Bold" />
<TextBlock Text="{Binding Value, StringFormat=': {0}'}" />
</StackPanel>
</HierarchicalDataTemplate>
</Grid.Resources>
<telerik:RadTreeView Name="JsonTreeView"
ItemsSource="{Binding SelectedItemInContent.MediaTreeInfoJson}"
IsVirtualizing="True"
SelectionMode="Extended"
ItemTemplate="{StaticResource ItemTemplateTree}"
/>
</Grid>
But if I try to change the ItemContainerStyle like in the Demo examples "ShuttleControl_WPF", the whole tree disappears. As if it doesn't have a properly defined Style.
<Style x:Key="nodeStyle" TargetType="telerik:RadTreeViewItem">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
</Style>
The model I use for Items is as follows:
public class JsonInfoTreeModel: ViewModelBase
{
private string name;
private string value;
private ObservableCollection<JsonInfoTreeModel> children;
private bool isExpanded;
public JsonInfoTreeModel()
{
Children = new ObservableCollection<JsonInfoTreeModel>();
IsExpanded = true;
}
public string Name
{
get { return name; }
set
{
if (name != value)
{
name = value;
OnPropertyChanged(nameof(Name));
}
}
}
public string Value
{
get { return value; }
set
{
if (this.value != value)
{
this.value = value;
OnPropertyChanged(nameof(Value));
}
}
}
public ObservableCollection<JsonInfoTreeModel> Children
{
get { return children; }
set
{
if (children != value)
{
children = value;
OnPropertyChanged(nameof(Children));
}
}
}
public bool IsExpanded
{
get { return isExpanded; }
set
{
if (isExpanded != value)
{
isExpanded = value;
OnPropertyChanged(nameof(IsExpanded));
}
}
}
}
Thank you for any help.
************** Update ****************
ExamleDesk.WPF.zip