Hi,
for some reason the binding of IsExpanded does nothing, visibility however works fine.
<grids:TreeListBox
Name="ProjectTreeListBox"
Grid.Row="2"
IsRootItemVisible="False"
RootItem="{Binding Projects}">
<grids:TreeListBox.ItemAdapter>
<grids:TreeListBoxItemAdapter ChildrenBinding="{Binding Children}" TopLevelExpandabilityDefault="Auto" />
</grids:TreeListBox.ItemAdapter>
<grids:TreeListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image
Width="16"
Height="16"
Stretch="None">
</Image>
<TextBlock
Margin="4,0,0,0"
Text="{Binding Name}"
TextTrimming="CharacterEllipsis" />
</StackPanel>
</DataTemplate>
</grids:TreeListBox.ItemTemplate>
<grids:TreeListBox.ItemContainerStyle>
<Style TargetType="{x:Type grids:TreeListBoxItem}">
<Setter Property="IsExpanded" Value="{Binding Path=Expanded}" />
<Setter Property="Visibility" Value="{Binding Path=Visible, Converter={StaticResource BoolToVis}}" />
</Style>
</grids:TreeListBox.ItemContainerStyle>
</grids:TreeListBox>
For testing purpose I've also tried changing the line to
<Setter Property="IsExpanded" Value="True" />
But all treeitems are collapsed. I'm aware of the IsExpandedBinding property but this doesn't seem work with binding to ReactiveProperty which requires binding to a nested property. For example the binding would look like
public ReactiveProperty<bool> Expanded { get; set;} = new ReactiveProperty<bool>();
IsExpandedBinding="{Binding Expanded.Value}"
That's why I wanted to do this in the style of treelistboxitem.
[Modified 7 years ago]