This is a migrated thread and some comments may be shown as answers.

Hierarchical Grouping and Filtering with TreeView WPF

1 Answer 211 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 19 Jan 2017, 09:31 AM
Hierarchical Grouping and Filtering with TreeView WPF

Hello,

After long searches, I have finally found a way to (somehow) achieve my requirement to display my Resources in some sort of Hierarchical groups, through a TreeView.
This works quite well, as the TreeView can even be seen as a row header in some way.

However, I got some new Requirements.
I need to display my Treeview in another part of my View (or even hide it)
Therefore, I thought, that it might be possible to modify my CustomGroupHeaderContentTemplateSelector to Bind its Content (instead of an empty Content)

<telerik:GroupHeaderTemplateSelector x:Key="CustomGroupHeaderContentTemplateSelector">
    <telerik:GroupHeaderTemplateSelector.HorizontalTemplate>
        <DataTemplate>
            <ContentPresenter Content="{Binding FormattedName}" Height="16" Margin="4"/>
        </DataTemplate>
    </telerik:GroupHeaderTemplateSelector.HorizontalTemplate>
    <telerik:GroupHeaderTemplateSelector.VerticalTemplate>
        <DataTemplate>
            <ContentPresenter Content="" Height="16" VerticalAlignment="Top" />
        </DataTemplate>
    </telerik:GroupHeaderTemplateSelector.VerticalTemplate>
</telerik:GroupHeaderTemplateSelector>

to

<telerik:GroupHeaderTemplateSelector x:Key="CustomGroupHeaderContentTemplateSelector">
            <telerik:GroupHeaderTemplateSelector.HorizontalTemplate>
                <DataTemplate>
                    <ContentPresenter Content="{Binding FormattedName}" Height="16" Margin="4"/>
                </DataTemplate>
            </telerik:GroupHeaderTemplateSelector.HorizontalTemplate>
            <telerik:GroupHeaderTemplateSelector.VerticalTemplate>
                <DataTemplate>
                    <ContentPresenter Content="{Binding}" Height="16" VerticalAlignment="Top" />
                </DataTemplate>
            </telerik:GroupHeaderTemplateSelector.VerticalTemplate>
        </telerik:GroupHeaderTemplateSelector>

       
On Start, the application works (and displays its data) as expected
BUT,
I came across a MAJOR PROBLEM that you can reproduce in attached sample
When you collapse both items of the TreeView - then expand one (look at header of each row) - then collapse it - then expand it again, you can see that the header text has changed in a way I cannot re-enact (take a look at attached pictures)

My questions now are:
What causes this kind of behaviour?
Is there a way I can avoid this Problem?
What do you recommend, to achieve my Requirements?

P.S.: - The sample is one of yours (Telerik), with only the slight change/add of a binding
        - Yes I even tried it with the latest telerik release 2017.1.117
        - As it is still not possible to add a .rar file to a post in your forum I hosted the sample project at onedrive: https://1drv.ms/u/s!AqROZw-XiIMygxUHdEcNdVy83H-y

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 23 Jan 2017, 01:57 PM
Hello Thomas,

I managed to reproduce the reported behavior and actually it's expected. The reason for it is the recycling logic for group headers implemented in RadScheduleView due to performance improvements. I am afraid that I cannot suggest a way to achieve the required behavior with the GroupHeaders - RadScheduleView does not support hierarchical grouping and the SDK example demonstrates an approach to achieve it to some extent with the help of the TreeView. So, in the concrete case, I'd suggest you modify the style of the TreeView items to make them look like the group headers.

Lastly, please note that only image files can be attached in our forums. If you need to send us a sample project,  you will have to open a support ticket and attach it there.

Regards,
Yana
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
ScheduleView
Asked by
Thomas
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or