Search code examples
wpfxamldata-bindingtreeviewmultibinding

MultiBinding in a TreeView Collapses TreeViewItems when One of the Bindings value changed


I have a TreeView thats binding to an Object of Type View with an attribute Name and two Lists. When i add Elements in one of the expanded Lists it stays expanded and thats what i want . The Problem is when i change The Name of View1 all the Multibinging Bindings are refreshed and all expanded Lists if any in the View1 collapses, but the View1 is still expanded . Is there any Way to avoid this behaviour so that when the value of the Name changes the converter somehow only changes the changed Value without collasing other Bindings . Thank you

<HierarchicalDataTemplate DataType="{x:Type local:View}">
    <HierarchicalDataTemplate.ItemsSource>
        <MultiBinding Converter="{StaticResource folderConverter}" ConverterParameter=",A,B">
            <Binding Path="Name"/>
            <Binding Path="List1"/>
            <Binding Path="List2"/>
        </MultiBinding>
    </HierarchicalDataTemplate.ItemsSource>`

Solution

  • Your setup looks like something in which a CompositeCollection might help, it should prevent the complete recreation of the ItemsSource even if you change a part.