Problem with TreeViewEx.ItemTemplate

Nov 30, 2012 at 12:14 PM
Is there a way to get the TreeViewEx.ItemTemplate working?
       <tvx:TreeViewEx.ItemTemplate>
            <tvx:HierarchicalDataTemplateEx ItemsSource="{Binding Path=Children}">
                <StackPanel Orientation="Horizontal">
                    <ContentControl Width="12"
                                    Height="12"
                                    Margin="2"
                                    Foreground="{Binding Path=Color}"
                                    Background="White"
                                    Template="{Binding Path=ResourceKey, Converter={StaticResource ControlTemplate}}" />
                    <TextBlock Text="{Binding Path=(gs:ITreeViewDisplayable.DisplayName)}" />
                </StackPanel>
            </tvx:HierarchicalDataTemplateEx>
        </tvx:TreeViewEx.ItemTemplate>
The "Children" do not have a common base datatype.
Coordinator
Dec 3, 2012 at 4:02 PM

Surely, but I probably have to implement it. ;-) I try to look at it at the weekend.

 

Regards, Torsten

Coordinator
Dec 12, 2012 at 7:31 PM

Ok, it took a little bit longer, but it should work now. I've changed the simple sample, in order to demonstrate.

Dec 17, 2012 at 12:11 PM

Thank you.

Now i have some difficulties with a load on demand scenario. My static dummy tree view object gets added multiple times in the TreeViewItemEx hashtable which throws an exception.

Could you add a "load on demand" example project to the solution?

Coordinator
Dec 19, 2012 at 8:18 PM

To clarify the problem: The error probably occures not because the loading on demand, it happens because you put the same object into the datacontext. Is that correct?

What do you mean with 'LoadOnDemand'? Do we talk about virtualization (http://blogs.microsoft.co.il/blogs/tomershamam/archive/2009/09/06/ui-virtualization-vs-data-virtualization.aspx)? Data or UI? There is an UI-Virtuallization example in the source control.

Jan 2, 2013 at 2:38 PM

Hi, sorry for the late response.

The treeview has to represent the same object at different nodes. I think that the treeviewex class uses a hashtable where these objects are used as keys. That is where the exception occurs.

By 'LoadOnDemand' I mean a sort of data virtualization. Only if you expand a node in the tree view for the first time, the program loads the children from a datasource (and creates the viewmodels for the treeviewexitems) (http://www.codeproject.com/Articles/26288/Simplifying-the-WPF-TreeView-by-Using-the-ViewMode).

 

 

Coordinator
Feb 8, 2013 at 2:43 PM
This problem should be fixed with changeset 70679.