Multilevel resource grouping parent

9 posts, 1 answers
  1. Oscar Wahlen
    Oscar Wahlen avatar
    33 posts
    Member since:
    Mar 2010

    Posted 18 Apr 2011 Link to this post

    Is it possible with multilevel resource grouping to get the parent resource group (the date grouping in particular)? In the attached screenshot I have multiple resource groups. In the lowerlevel resource group I want access to the toplevel date grouping. Is this supported?
  2. Answer
    Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 18 Apr 2011 Link to this post

    Hello Oscar,

    Yes, this is supported, the GroupHeader class has a property named ParentKeys that holds the needed information. GroupHeader is the UI element of the group and to access the property you need to create a custom control template.

    We will consider adding this property to the DataContext to allow the developers to use it in a DataTemplate, but currently the only way to access it is through a custom control template for GroupHeader.

    Regards,
    Valeri Hristov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. ryan
    ryan avatar
    9 posts
    Member since:
    Mar 2008

    Posted 06 May 2011 Link to this post

    is there an example of this anywhere?
  5. Oscar Wahlen
    Oscar Wahlen avatar
    33 posts
    Member since:
    Mar 2010

    Posted 09 May 2011 Link to this post

    Hi ryan,

    You can change the MainPage.xaml code in this example to display the parent keys in a regular ComboBox control.

    MainPage.xaml

    <UserControl xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"  x:Class="GroupHeaderTest.MainPage"
        xmlns:local="clr-namespace:GroupHeaderTest"
        mc:Ignorable="d" d:DesignHeight="500" d:DesignWidth="600">
      
        <UserControl.Resources>
            <local:MyViewModel x:Key="MyViewModel" />
            <local:ResourceToImageConverter x:Key="ResourceToImageConverter" />
      
            <ControlTemplate x:Key="MyGroupHeaderTemplate" TargetType="telerik:GroupHeader">
                <Grid>
                    <VisualStateManager.VisualStateGroups>
                        <VisualStateGroup x:Name="OrientationStates">
                            <VisualState x:Name="Horizontal">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="VerticalAlignment" Storyboard.TargetName="Header">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Stretch"/>
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="HorizontalAlignment" Storyboard.TargetName="Header">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Left"/>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                            <VisualState x:Name="Vertical">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="HeaderOuterBorder">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                            <DiscreteObjectKeyFrame.Value>
                                                <Visibility>Collapsed</Visibility>
                                            </DiscreteObjectKeyFrame.Value>
                                        </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="HeaderOuterBorderVertical">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0">
                                            <DiscreteObjectKeyFrame.Value>
                                                <Visibility>Visible</Visibility>
                                            </DiscreteObjectKeyFrame.Value>
                                        </DiscreteObjectKeyFrame>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                        <VisualStateGroup x:Name="DayStates">
                            <VisualState x:Name="NormalDay"/>
                            <VisualState x:Name="Today">
                                <Storyboard>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="HeaderOuterBorderVertical">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GroupHeaderHeaderOuterBorder_Today}"/>
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="HeaderOuterBorderVertical">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GroupHeaderHeaderBackground_Today}"/>
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="HeaderInnerBorderVertical">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GroupHeaderHeaderInnerBorder_Today}"/>
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="HeaderOuterBorder">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GroupHeaderHeaderOuterBorder_VerticalToday}"/>
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="HeaderOuterBorder">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GroupHeaderHeaderBackground_VerticalToday}"/>
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="HeaderInnerBorder">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GroupHeaderHeaderInnerBorder_VerticalToday}"/>
                                    </ObjectAnimationUsingKeyFrames>
                                    <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderThickness" Storyboard.TargetName="Border">
                                        <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GroupHeaderTodayBorderThickness}"/>
                                    </ObjectAnimationUsingKeyFrames>
                                </Storyboard>
                            </VisualState>
                        </VisualStateGroup>
                    </VisualStateManager.VisualStateGroups>
                    <Border x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1" Background="{TemplateBinding Background}" HorizontalAlignment="Stretch" IsHitTestVisible="False" VerticalAlignment="Stretch"/>
                    <Grid x:Name="Header" HorizontalAlignment="Stretch" VerticalAlignment="Top">
                        <Border x:Name="HeaderOuterBorder" BorderBrush="{StaticResource GroupHeaderHeaderOuterBorder_Vertical}" BorderThickness="1" Background="{StaticResource GroupHeaderHeaderBackground_Vertical}">
                            <Border x:Name="HeaderInnerBorder" BorderBrush="{StaticResource GroupHeaderHeaderInnerBorder_Vertical}" BorderThickness="1"/>
                        </Border>
                        <Border x:Name="HeaderOuterBorderVertical" BorderBrush="{StaticResource GroupHeaderHeaderOuterBorder}" BorderThickness="1" Background="{StaticResource GroupHeaderHeaderBackground}" Visibility="Collapsed">
                            <Border x:Name="HeaderInnerBorderVertical" BorderBrush="{StaticResource GroupHeaderHeaderInnerBorder}" BorderThickness="1"/>
                        </Border>
                        <StackPanel Orientation="Vertical">
                            <TextBlock Text="{Binding Name}" />
                            <ComboBox ItemsSource="{Binding ParentKeys, RelativeSource={RelativeSource TemplatedParent}}" SelectedItem="{Binding ParentKeys[0], RelativeSource={RelativeSource TemplatedParent}}" />
                        </StackPanel>
                    </Grid>
                </Grid>
            </ControlTemplate>
      
            <telerik:OrientedGroupHeaderStyleSelector x:Key="OrientedGroupHeaderStyleSelector">
                <telerik:OrientedGroupHeaderStyleSelector.HorizontalStyle>
                    <Style BasedOn="{StaticResource HorizontalGroupHeaderStyle}" TargetType="telerik:GroupHeader">
                        <Setter Property="Template" Value="{StaticResource MyGroupHeaderTemplate}" />
                    </Style>
                </telerik:OrientedGroupHeaderStyleSelector.HorizontalStyle>
            </telerik:OrientedGroupHeaderStyleSelector>
      
            <telerik:OrientedGroupHeaderContentTemplateSelector x:Key="GroupHeaderContentTemplateSelector">
                <telerik:OrientedGroupHeaderContentTemplateSelector.HorizontalDayViewDateTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Name, StringFormat=%d}" FontWeight="Bold" Margin="4,0,0,0" />
                            <TextBlock Text="{Binding Name, StringFormat=dddd}" Margin="4,0,0,0" />
                        </StackPanel>
                    </DataTemplate>
                </telerik:OrientedGroupHeaderContentTemplateSelector.HorizontalDayViewDateTemplate>
                <telerik:OrientedGroupHeaderContentTemplateSelector.HorizontalResourceTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="{Binding Converter={StaticResource ResourceToImageConverter}}" Height="16" Width="16" Margin="4,0,0,0" />
                            <TextBlock Text="{Binding Name}" Margin="4,0" />
                        </StackPanel>
                    </DataTemplate>
                </telerik:OrientedGroupHeaderContentTemplateSelector.HorizontalResourceTemplate>
            </telerik:OrientedGroupHeaderContentTemplateSelector>
        </UserControl.Resources>
      
        <Grid DataContext="{StaticResource MyViewModel}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
      
            <StackPanel>
                <StackPanel Orientation="Horizontal">
                    <CheckBox IsChecked="{Binding IsBusinessUnitVisible, Mode=TwoWay}">
                        <CheckBox.Content>
                            <TextBlock Text="Business Unit" />
                        </CheckBox.Content>
                    </CheckBox>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <CheckBox IsChecked="{Binding IsTeamVisible, Mode=TwoWay}">
                        <CheckBox.Content>
                            <TextBlock Text="Team" />
                        </CheckBox.Content>
                    </CheckBox>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <CheckBox IsChecked="{Binding IsEmployeeVisible, Mode=TwoWay}">
                        <CheckBox.Content>
                            <TextBlock Text="Employee" />
                        </CheckBox.Content>
                    </CheckBox>
                </StackPanel>
            </StackPanel>
      
            <telerik:RadScheduleView Grid.Column="1" AppointmentsSource="{Binding Appointments}"
                                     ResourceTypesSource="{Binding ResourcesTypes}"
                                     GroupDescriptionsSource="{Binding GroupDescriptions}"
                                     GroupHeaderStyleSelector="{StaticResource OrientedGroupHeaderStyleSelector}"
                                     GroupHeaderContentTemplateSelector="{StaticResource GroupHeaderContentTemplateSelector}">
      
                <telerik:RadScheduleView.ViewDefinitions>
                    <telerik:DayViewDefinition GroupFilter="{Binding GroupFilter}" />
                </telerik:RadScheduleView.ViewDefinitions>
      
            </telerik:RadScheduleView>
      
        </Grid>
    </UserControl

    And add the following XAML code to the application resource dictionary.

    App.xaml
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                 x:Class="GroupHeaderTest.App"
                 >
        <Application.Resources>
            <ResourceDictionary Source="/Telerik.Windows.Themes.Windows7;component/themes/windows7/scheduleview.xaml" />
        </Application.Resources>
    </Application>
  6. Joel
    Joel avatar
    41 posts
    Member since:
    Nov 2010

    Posted 22 Jun 2011 Link to this post

    I am attempting to do this, but all of the static resources that (I think) are supposed to come out of the application resources defined in App.xaml are flagged as "The resource xxx could not be resolved".

    This happens for everything that isn't specified in MainPage.xaml, but here's a few examples: GroupHeaderHeaderOuterBorder_Today, GroupHeaderHeaderBackground_Today, GroupHeaderHeaderInnerBorder_Today, GroupHeaderHeaderOuterBorder_VerticalToday

    What am I missing?
  7. Joel
    Joel avatar
    41 posts
    Member since:
    Nov 2010

    Posted 22 Jun 2011 Link to this post

    I was missing a reference to Telerik.Windows.Themes.Windows7.dll.
  8. Joel
    Joel avatar
    41 posts
    Member since:
    Nov 2010

    Posted 15 Jul 2011 Link to this post

    I upgraded to the most recent bits and am experiencing this issue again.  Did something change with the Telerik.Windows.Themes.Windows7.dll?

    Specifically, Visual Studio says "The resource xxx could not be resolved.", where xxx is (among others) GroupHeaderHeaderOuterBorder_Today, GroupHeaderHeaderBackground_Today, GroupHeaderHeaderInnerBorder_Today, GroupHeaderTodayBorderThickness.  Last time I was able to fix this by referencing Telerik.Windows.Themes.Windows7, but it seems like these resources are inaccessible or have been moved. 

    If I try to run the app, I get an unhandled exception "The given key was not present in the dictionary.", which seems like it would come from not being able to find these resources.

    Has the workaround for accessing the parents of group header items changed?
  9. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 21 Jul 2011 Link to this post

    Hi Joel,

    The issue here is that the template of the ScheduleView is changed in the Q2 2011. You have to find the differences or add the new style from Q2 and edit it to fit your requirements. These brushes are no longer used in the style.
    Sorry for the caused inconvenience.

    Regards,
    Konstantina
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  10. Vignesh
    Vignesh avatar
    1 posts
    Member since:
    Sep 2011

    Posted 04 Dec 2012 Link to this post

    Hi Oscar!
                      Can you send me the project you are doing because i have seen your attachment,i need the design.Help me
Back to Top
DevCraft banner