Horizontal grouping names and max height

8 posts, 0 answers
  1. Pete
    Pete avatar
    67 posts
    Member since:
    Sep 2012

    Posted 31 Aug 2011 Link to this post

    I have a horizontal timeline (as in http://demos.telerik.com/silverlight/#ScheduleView/Grouping/GroupingAndFiltering) with groupings (people's names)
    I would like to be able to put the names horizonally instead of vertically - is this possible? I haven't found a textblock control in the template for the scheduleview where I might do this.

    Secondly, I would like to set a fixed height for my grouping rows.

    Thanks in advance
  2. Pete
    Pete avatar
    67 posts
    Member since:
    Sep 2012

    Posted 31 Aug 2011 Link to this post

    I've partially figured out the answer; I have removed the RotateTransform in the template for the GroupHeaderContentTemplateSelector.

    This changes the resource names to horizontal however, on the day view I would like to remove the day label that appears next to the resource group headers. Also, on the week view, I would like the label for the day to just display the date rather than "31 Wednesday" etc.

    Thanks
  3. Rosi
    Admin
    Rosi avatar
    2529 posts

    Posted 01 Sep 2011 Link to this post

    Hello Xamlmax,

    Removing the day headers from day view is not possible at this moment. However you can remove the text by using Formatting strings that are described in details here.

    For the week view you can use again Formatting Strings to implement the task.
    As for the Height property of the headers -you can set the StrechGroupHeaders property of the definition to False. This will measure all headers with the same size.

    More about styling the group headers you can find in the links below:
    http://www.telerik.com/help/silverlight/radscheduleview-styles-and-templates-styling-groupheaders.html
    http://demos.telerik.com/silverlight/#ScheduleView/CustomStyles/GroupHeaderTemplate

    Kind regards,
    Rosi
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  4. Pete
    Pete avatar
    67 posts
    Member since:
    Sep 2012

    Posted 02 Sep 2011 Link to this post

    Thanks. That worked well.
    The remaining problem I have is with the resource group names not  stretching to fit. I've attached a picture to illustrate.
    In the GroupHeaderTemplateSelector.VerticalTemplate I have tried settings HorizontalAlignment and HorizontalContentAlignment of the
    LayoutTransformControl and the ContentPresent to 'Stretch'.

    <telerik:GroupHeaderTemplateSelector.VerticalTemplate>
                <DataTemplate>
                    <telerik:LayoutTransformControl VerticalAlignment="Top" HorizontalAlignment="Stretch"  HorizontalContentAlignment="Stretch">
                        <!--<telerik:LayoutTransformControl.LayoutTransform>
                            <RotateTransform Angle="-90" />
                        </telerik:LayoutTransformControl.LayoutTransform>-->
                        <ContentPresenter Content="{Binding FormattedName}" Margin="4 1" Height="16"  HorizontalAlignment="Stretch" />
                    </telerik:LayoutTransformControl>
                </DataTemplate>
            </telerik:GroupHeaderTemplateSelector.VerticalTemplate>
  5. Dani
    Admin
    Dani avatar
    848 posts

    Posted 05 Sep 2011 Link to this post

    Hello Pete,

    You can simply add a MinWidth in your modified DataTemplate. If the MinWidth is equal to the longest group header of all group headers, then all of them would stretch. This is an easy way to accomplish the task, without including any excessive xaml code into your project.

    <Grid MinWidth="300">
          <ContentPresenter Content="{Binding FormattedName}" Margin="4" Height="16" />
    </Grid>

    I hope this will be helpful.


    Kind regards,
    Dani
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  6. Pete
    Pete avatar
    67 posts
    Member since:
    Sep 2012

    Posted 05 Sep 2011 Link to this post

    I have bound the grid width to a ValueConverter to return a different width for each resource type.

    This works OK until I remove 1 of the groupings (I have a checkbox which allows the user to switch 1 of the groupings on/off, which adds/removes an item from the collection that is bound to the ResourceTypesSource).

    When I update the ResourceTypesSource the scheduler runs through the converter for the some of the items (those that are then set to the correct width), but not all - see attached image.

    Is there a way to force the scheduleview to re-render the resource group headings again?

    Thanks

  7. Rosi
    Admin
    Rosi avatar
    2529 posts

    Posted 07 Sep 2011 Link to this post

    Hello Xamlmax,

    This is a strange problem. Is it possible to send us sample running project that we can test locally?

    Best wishes,
    Rosi
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  8. Martha
    Martha avatar
    26 posts
    Member since:
    Aug 2011

    Posted 11 Oct 2011 Link to this post

    The way I've gotten it to work is to derive my own Resouce class & set it's MinWidth property in my view model.
    I actually calculate the min width based on all the text in the resources of that type so it is dynamic.
    public class BedResource : Resource
    {
        public BedResource() : base() {}
        public BedResource(string name) : base(name) { }
        public BedResource(string name, string type) : base(name, type) { }
        public Int32 MinWidth { get; set; }
    }

    Then bind this new property in the data template ( MinWidth="{Binding Name.MinWidth}" )
    It rebinds whenever the resources change, so the width is reset each time
    <local:GroupHeaderContentTemplateSelector x:Key="GroupHeaderContentTemplateSelector">
        <local:GroupHeaderContentTemplateSelector.VerticalNotRotatedTemplate>
            <DataTemplate>
                <telerikPrimitives:LayoutTransformControl  MinWidth="{Binding Name.MinWidth}" >
                    <ContentPresenter Content="{Binding FormattedName}" />
                </telerikPrimitives:LayoutTransformControl>
            </DataTemplate>
        </local:GroupHeaderContentTemplateSelector.VerticalNotRotatedTemplate>
        <local:GroupHeaderContentTemplateSelector.VerticalRotatedTemplate>
            <DataTemplate>
                <telerikPrimitives:LayoutTransformControl VerticalAlignment="Top" >
                    <telerikPrimitives:LayoutTransformControl.LayoutTransform>
                        <RotateTransform Angle="-90" />
                    </telerikPrimitives:LayoutTransformControl.LayoutTransform>
                    <ContentPresenter Content="{Binding FormattedName}" Margin="4 1" Height="16" />
                </telerikPrimitives:LayoutTransformControl>
            </DataTemplate>
        </local:GroupHeaderContentTemplateSelector.VerticalRotatedTemplate>
    </local:GroupHeaderContentTemplateSelector>

    The GroupHeaderContentSelector also selects vertical or horizontal based on the resource type
    public class GroupHeaderContentTemplateSelector : GroupHeaderTemplateSelector
    {
        public DataTemplate VerticalNotRotatedTemplate { get; set; }
        public DataTemplate VerticalRotatedTemplate { get; set; }
     
        public override DataTemplate SelectTemplate(object item, DependencyObject container, ViewDefinitionBase activeViewDeifinition)
        {
            Resource resource = (Resource)item;
            if (resource.ResourceType == "Bed")
            {
                return VerticalNotRotatedTemplate;
            }
            else if (resource.ResourceType == "Unit")
            {
                return VerticalRotatedTemplate;
            }
            return base.SelectTemplate(item, container, activeViewDeifinition);
        }
    }

    I have attached a picture of what the resources look like.

Back to Top