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

Group radio button per parent level

1 Answer 26 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
HDC
Top achievements
Rank 1
HDC asked on 13 May 2012, 07:05 AM
I have following tree view:

Desert
       Fruit
       Ice Cream 
       Cake
Soup
        Tomato soup
        Vegetable soup

There are only radio buttons on 2nd level (fruit, ice cream, cake, tomato soup, vegetable soup). When i select an item from desert, the choice made in soup is removed. How can i group this per parent, it think it must have something to do with the GroupName property, but i can't figure out how to bind with the parent node

This is my XAML:
<navigation:Page.Resources>
        <DataTemplate x:Key="MealMenuAlternateDiet">
            <TextBlock Text="{Binding Description}" />
        </DataTemplate>
        <telerik:HierarchicalDataTemplate x:Key="MealMenu" ItemTemplate="{StaticResource MealMenuAlternateDiet}"
           ItemsSource="{Binding Diets}">
            <RadioButton Content="{Binding Description}" IsChecked="{Binding IsSelected, Mode=TwoWay}" FontSize="12"/>
        </telerik:HierarchicalDataTemplate>
        <telerik:HierarchicalDataTemplate x:Key="Meal" ItemTemplate="{StaticResource MealMenu}"
           ItemsSource="{Binding MealMenus}">
            <TextBlock Text="{Binding Description}" />           
        </telerik:HierarchicalDataTemplate>
    </navigation:Page.Resources>

And my tree
<telerik:RadTreeView Grid.Row="2"
            ItemsSource="{Binding Source={StaticResource DataContextProxy}, Path=DataSource.Meals}"
            ItemTemplate="{StaticResource Meal}" />

Thanks,

Peter


1 Answer, 1 is accepted

Sort by
0
HDC
Top achievements
Rank 1
answered on 13 May 2012, 07:52 AM
Just had an "aha" moment...

it is actually quite simple, maybe somebody else will look for this...
 
The solution is to add a property "Group" to the class bound on second level , then you make sure that property contains the id of the parent node. Then in the template you bind the "GroupName" property of the radiobutton to that property "Group".

That's it...




Tags
TreeView
Asked by
HDC
Top achievements
Rank 1
Answers by
HDC
Top achievements
Rank 1
Share this question
or