Group radio button per parent level

2 posts, 0 answers
  1. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 13 May 2012 Link to this post

    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


  2. HDC
    HDC avatar
    214 posts
    Member since:
    Dec 2010

    Posted 13 May 2012 Link to this post

    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...




  3. DevCraft banner
Back to Top