Treelistbox IsExpanded xaml binding

Posted 2 months ago by Avatar Mike


for some reason the binding of IsExpanded does nothing, visibility however works fine.

            RootItem="{Binding Projects}">
                <grids:TreeListBoxItemAdapter ChildrenBinding="{Binding Children}" TopLevelExpandabilityDefault="Auto" />
                    <StackPanel Orientation="Horizontal">
                            Text="{Binding Name}"
                            TextTrimming="CharacterEllipsis" />
                <Style TargetType="{x:Type grids:TreeListBoxItem}">
                    <Setter Property="IsExpanded" Value="{Binding Path=Expanded}" />
                    <Setter Property="Visibility" Value="{Binding Path=Visible, Converter={StaticResource BoolToVis}}" />

 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 2 months ago]

Comments (1)

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA


Per the "Expandability" documentation topic:

The TreeListBoxItemAdapter.IsExpandedPath property specifies the property name to watch for in case your item implements INotifyPropertyChanged. When a change to that property is detected, the updated value will be requested by the control. Note that even though a binding can be used via the IsExpandedBinding property, for performance reasons, it is just used temporarily to get/set the value in the adapter methods' default implementations. The binding doesn't persist, and that's why the IsExpandedPath property is required for property change notifications.

IsExpandedPath must be used so that the adapter knows to refresh its value, even when IsExpandedBinding is used.  IsExpandedPath can only be one level though (i.e. "Expanded") and not "Expanded.Value".  

If you'd like us to look into a problem you're having, please make a new simple sample project that shows the issue and send that to our support address, referencing this thread in your email.  Be sure to exclude the bin/obj folders from the ZIP you send and rename the .zip file extension so it doesn't get spam blocked.  Then we can debug it to see what's going on.  Thanks!

Actipro Software Support
Information The latest build of this product (2018.1 build 0670) was released 4 days ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.