Treelistbox IsExpanded xaml binding

Grids for WPF Forum

Posted 6 years ago by Mike
Version: 17.2.0665
Platform: .NET 4.7
Environment: Windows 10 (64-bit)


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 6 years ago]

Comments (1)

Posted 6 years 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

The latest build of this product (v24.1.2) was released 26 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.