Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
30
Filtering XamDataTree with ReactiveUI
posted

While trying to replace a TreeView with a XamDataTree I experience problems when clearing an applied filter. The first code snippets shows the working version using a TreeView.

  <TreeView Grid.Column="0" Grid.Row="1"
                              ItemsSource="{Binding TrendGroupViewModels}"
                              DataContext="{Binding TrendGroups }"
                              VirtualizingStackPanel.IsVirtualizing="True"
                              VirtualizingStackPanel.VirtualizationMode="Recycling">
                        <TreeView.Resources>
                            <Style TargetType="{x:Type TreeViewItem}">
                                <Setter Property="IsExpanded"
                                        Value="{Binding IsExpanded,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
                                <Setter Property="IsSelected"
                                        Value="{Binding IsSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
                            </Style>

                            <HierarchicalDataTemplate DataType="{x:Type viewModels:TrendGroupViewModel}"
                                                      ItemsSource="{Binding Inferiors}">

The TreeView code has been replaced with the following XamDataTree code.

 <ig:XamDataTree
    IsExpandedMemberPath="IsExpanded"
    IsSelectedMemberPath="IsSelected"
    ItemsSource="{Binding TrendGroupViewModels}"
    DataContext="{Binding TrendGroups }"

    VirtualizingStackPanel.IsVirtualizing="True"
    VirtualizingStackPanel.VirtualizationMode="Recycling"

    <ig:XamDataTree.GlobalNodeLayouts>
        <ig:NodeLayout
            TargetTypeName="IAkzGroupTreeViewModel"
            DisplayMemberPath="TypeName"
            Key="Inferiors" />
        </ig:XamDataTree.GlobalNodeLayouts>

Each node is provided with a BehaviorSubject that filters the nodes children when

_filter.OnNext(node => additonalNodes.Contains(id));

 is called.

BehaviorSubject<Func<Node<ITreeItemDto, Guid>, bool>> _subFilter =
            new BehaviorSubject<Func<Node<ITreeItemDto, Guid>, bool>>(node => true);

The initial lazy loading as well as first filter action work as expected. When the tree is partially unfolded, clearing the filter does not show the initial tree as expected. Filtered node siblings of unfolded nodes do not reload/refresh their children.

Secondly search results (nodes) are duplicated when expanded to before filtered sibling nodes.

Parents
No Data
Reply
  • 34430
    Offline posted

    Hello Marcel,

    I have done an initial investigation into the information provided on this forum thread, and unfortunately, from the code that you have provided, I can see how your XamDataTree is set up, but I cannot really tell exactly how the filtering or search operations are being carried out in this case. As the XamDataTree does not actually support filtering or search operations out-of-the-box, I believe an isolated sample project that demonstrates this behavior you are seeing will be necessary to continue to investigate this issue, as that would provide me with something to debug to determine what may be causing it.

    Would it be possible for you to please provide an isolated sample project that demonstrates the behavior you are seeing?

    Please let me know if you have any other questions or concerns on this matter.

Children