WeekViewDefinition Group Size Problem

11 posts, 0 answers
  1. Anthony
    Anthony avatar
    58 posts
    Member since:
    Aug 2011

    Posted 12 May 2015 Link to this post

    Hi,

     I have recently added filtering of resources on my WeekViewDefinition view.

     When there are 8 resources the layout looks fine, each day of the week for each resource is a good size. See Good.jpg

     If I filter one of the resources, each day of the week gets resized and becomes way too large. See Bad.jpg.

     Any help would be appreciated as the view is unusable when the days become so large.

     Thanks

    Anthony

  2. Anthony
    Anthony avatar
    58 posts
    Member since:
    Aug 2011

    Posted 13 May 2015 in reply to Anthony Link to this post

    Hi,

    I forgot to mention that I am using a GroupHeaderContentTemplateSelector.

    I think the issue has something to with the wrong container being used between the date group and resource group.

    I had a width set of 600 on my resource group, which if accidentally used in some way on the date group would explain the stretching of the days.

    I also get a binding error "BindingExpression path error: 'DisplayName' property not found on 'object' ''DateTime' (HashCode=-2043258476)'. BindingExpression:Path=Name.DisplayName; DataItem='GroupHeaderProxy' (HashCode=33854279); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')"

    That does not make sense because the GroupHeaderContentTemplateSelector should provide the following template when the group is a date. Note that the template does not use "DisplayName" anywhere, that is only used in the template for the resource group. Again this indicates the use of the wrong template.

                    <DataTemplate>
                        <Grid>
                            <TextBlock Margin="6,0,0,0" FontWeight="Bold" Text="{Binding Name, StringFormat=dd}"/>
                            <TextBlock Margin="0,0,6,0" Text="{Binding Name, StringFormat=ddd}" TextAlignment="Right"/>
                        </Grid>

    Thanks

    Anthony

     

     

  3. UI for WPF is Visual Studio 2017 Ready
  4. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 14 May 2015 Link to this post

    Hi Anthony,

    Can you please share some more sample code (the GroupHeaderContentTemplateSelector and the GroupFilter code) so we can test the explained scenario? Also have you modified the GroupHeader styles and which version of the control are you using?

    I'm looking forward to hearing from you.

    Regards,
    Kalin
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  5. Anthony
    Anthony avatar
    58 posts
    Member since:
    Aug 2011

    Posted 14 May 2015 in reply to Kalin Link to this post

    Hi, 

    I am using the latest release version of the control. I have not modified the GroupHeader styles.

    Thanks

    Anthony

     GroupHeaderContentTemplateSelector:

    public class CustomGroupHeaderContentTemplateSelector : ScheduleViewDataTemplateSelector
    {
        public DataTemplate DayHorizontalDateTemplate { set; get; }
        public DataTemplate WeekHorizontalDateTemplate { set; get; }
        public DataTemplate MonthHorizontalDateTemplate { set; get; }
        public DataTemplate TimelineHorizontalDateTemplate { set; get; }
        public DataTemplate DayVerticalDateTemplate { set; get; }
        public DataTemplate WeekVerticalDateTemplate { set; get; }
        public DataTemplate MonthVerticalDateTemplate { set; get; }
        public DataTemplate TimelineVerticalDateTemplate { set; get; }
        public DataTemplate DayHorizontalResourceTemplate { set; get; }
        public DataTemplate WeekHorizontalResourceTemplate { set; get; }
        public DataTemplate MonthHorizontalResourceTemplate { set; get; }
        public DataTemplate TimelineHorizontalResourceTemplate { set; get; }
        public DataTemplate DayVerticalResourceTemplate { set; get; }
        public DataTemplate WeekVerticalResourceTemplate { set; get; }
        public DataTemplate MonthVerticalResourceTemplate { set; get; }
        public DataTemplate TimelineVerticalResourceTemplate { set; get; }
     
        public override DataTemplate SelectTemplate(object item, DependencyObject container, ViewDefinitionBase activeViewDefinition)
        {
            CollectionViewGroup cvg = item as CollectionViewGroup;
     
            if (cvg != null && cvg.Name is IResource)
            {
                if (activeViewDefinition.GetOrientation() == Orientation.Vertical)
                {
                    switch (activeViewDefinition.Title)
                    {
                        case "Day":
                        {
                            if (DayHorizontalResourceTemplate != null)
                            {
                                return DayHorizontalResourceTemplate;
                            }
                            break;
                        }
                        case "Week":
                        {
                            if (WeekHorizontalResourceTemplate != null)
                            {
                                return WeekHorizontalResourceTemplate;
                            }
                            break;
                        }
                        case "Month":
                        {
                            if (MonthHorizontalResourceTemplate != null)
                            {
                                return MonthHorizontalResourceTemplate;
                            }
                            break;
                        }
                        case "Timeline":
                        {
                            if (TimelineHorizontalResourceTemplate != null)
                            {
                                return TimelineHorizontalResourceTemplate;
                            }
                            break;
                        }
                    }
                }
                else
                {
                    switch (activeViewDefinition.ToString())
                    {
                        case "Day":
                        {
                            if (DayVerticalResourceTemplate != null)
                            {
                                return DayVerticalResourceTemplate;
                            }
                            break;
                        }
                        case "Week":
                        {
                            if (WeekVerticalResourceTemplate != null)
                            {
                                return WeekVerticalResourceTemplate;
                            }
                            break;
                        }
                        case "Month":
                        {
                            if (MonthVerticalResourceTemplate != null)
                            {
                                return MonthVerticalResourceTemplate;
                            }
                            break;
                        }
                        case "Timeline":
                        {
                            if (TimelineVerticalResourceTemplate != null)
                            {
                                return TimelineVerticalResourceTemplate;
                            }
                            break;
                        }
                    }
                }
            }
     
            if (cvg != null && cvg.Name is DateTime)
            {
                if (activeViewDefinition.GetOrientation() == Orientation.Vertical)
                {
                    switch (activeViewDefinition.Title)
                    {
                        case "Day":
                        {
                            if (DayHorizontalDateTemplate != null)
                            {
                                return DayHorizontalDateTemplate;
                            }
                            break;
                        }
                        case "Week":
                        {
                            if (WeekHorizontalDateTemplate != null)
                            {
                                return WeekHorizontalDateTemplate;
                            }
                            break;
                        }
                        case "Month":
                        {
                            if (MonthHorizontalDateTemplate != null)
                            {
                                return MonthHorizontalDateTemplate;
                            }
                            break;
                        }
                        case "Timeline":
                        {
                            if (TimelineHorizontalDateTemplate != null)
                            {
                                return TimelineHorizontalDateTemplate;
                            }
                            break;
                        }
                    }
                }
                else
                {
                    switch (activeViewDefinition.ToString())
                    {
                        case "Day":
                        {
                            if (DayVerticalDateTemplate != null)
                            {
                                return DayVerticalDateTemplate;
                            }
                            break;
                        }
                        case "Week":
                        {
                            if (WeekVerticalDateTemplate != null)
                            {
                                return WeekVerticalDateTemplate;
                            }
                            break;
                        }
                        case "Month":
                        {
                            if (MonthVerticalDateTemplate != null)
                            {
                                return MonthVerticalDateTemplate;
                            }
                            break;
                        }
                        case "Timeline":
                        {
                            if (TimelineVerticalDateTemplate != null)
                            {
                                return TimelineVerticalDateTemplate;
                            }
                            break;
                        }
                    }
                }
            }
     
            return base.SelectTemplate(item, container, activeViewDefinition);
        }
    }

    XAML: If I increase the width of the StackPanel in here the date group panel also grows by the same amount.

    <DataTemplate x:Key="WeekHorizontalResourceTemplate">
        <StackPanel Orientation="Horizontal" Width="200" Margin="5">
            <Viewbox Width="150" Height="40">
                <TextBlock Width="150" FontWeight="Bold" FontSize="18" Text="{Binding Name.DisplayName, FallbackValue=''}" TextWrapping="Wrap" TextAlignment="Center"/>
            </Viewbox>
            <Button Grid.Column="1" Margin="5,0,0,0" Width="20" Height="20">
                <Button.Content>
                    <Path Margin="2,1" Fill="Black" Data="M10,0 L0,6 10,12"/>
                </Button.Content>
            </Button>
            <Button Grid.Column="2" Margin="5,0,0,0" Width="20" Height="20">
                <Button.Content>
                    <Path Margin="2,1" Fill="Black" Data="M0,0 L10,6 0,12"/>
                </Button.Content>
            </Button>
        </StackPanel>
    </DataTemplate>

    <DataTemplate x:Key="WeekHorizontalDateTemplate">
        <Grid>
    <TextBlock Margin="6,0,0,0" FontWeight="Bold" Text="{Binding Name, StringFormat=dd}"/>
    <TextBlock Margin="0,0,6,0" Text="{Binding Name, StringFormat=ddd}" TextAlignment="Right"/>
    </Grid>
    </DataTemplate>

     

    Group Filter Code:

    public Func<object, bool> GroupFilter
    {
        get
        {
            return GroupFilterFunc;
        }
    }
     
    private bool GroupFilterFunc(object groupName)
    {
        bool ret = true;
     
        MechanicAllocationResource res = groupName as MechanicAllocationResource;
     
        if (res != null && res.IsShown == false)
        {
            ret = false;
        }
     
        return ret;
    }

  6. Anthony
    Anthony avatar
    58 posts
    Member since:
    Aug 2011

    Posted 03 Jun 2015 in reply to Anthony Link to this post

    Hi,

    Just wondering if there is any update on this issue?

    Thanks

    Anthony

  7. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 05 Jun 2015 Link to this post

    Hi Anthony,

    We would need some more details in order to be able to provide you a possible solution for this issue. Can you please share some more details - the GroupHeaderContentTemplateSelector and the GroupFilter code would be good starting point. Also have you modified the GroupHeader styles and which version of the control are you using? If you are able to provide sample runnable project that would be really helpful.

    I'm looking forward to hearing from you.

    Regards,
    Kalin
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  8. Anthony
    Anthony avatar
    58 posts
    Member since:
    Aug 2011

    Posted 05 Jun 2015 in reply to Kalin Link to this post

    Hi,

    I have already provided that information in a previous post. The only thing I didn't provide was a runnable solution.

    This issue is very easy to reproduce, just set the width of a resource header to be 1000 and then watch as the date header template grows larger when the containers are reused.

    Thanks

    Anthony

  9. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 05 Jun 2015 Link to this post

    Hello Anthony,

    First of all I would like to apologize for the misunderstanding and missing your previous post. However I tested the provided code snippets in a sample project based on them and I was not able to reproduce the described issue. Please find the sample project attached, test it on your side and let us know if anything additional needs to be done. Also you can try to use Grid instead of StackPanel in the GroupHeader template and see  if this solves the issue.

    I'm looking forward to hearing from you.

    Regards,
    Kalin
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  10. Anthony
    Anthony avatar
    58 posts
    Member since:
    Aug 2011

    Posted 08 Jun 2015 in reply to Kalin Link to this post

    Hi,

    Using your sample project I have not been able to reproduce the error in the same place, however I have produced a very similar error where the templates are being mixed up.

    Have a look at the screenshot which shows the last two resource groups being mixed up.

    I have attached the source code which will reproduce this every time. (Had to put .jpg extension on it to attach it)

    Thanks

    Anthony

  11. Kalin
    Admin
    Kalin avatar
    1209 posts

    Posted 10 Jun 2015 Link to this post

    Hi Anthony,

    The issue in the sample project is that you don't have any Templates defined for the DayViewDefitinition and in this case the Selector calls the base.SelectTemplate method which returns null and this causes the issue. What I can suggest you would be instead of calling the base method would be to implement default vertical and horizontal templates and to return them at the end of the selector. Check the attached sample project which demonstrates the exact approach.

    Hope this helps.

    Regards,
    Kalin
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  12. Anthony
    Anthony avatar
    58 posts
    Member since:
    Aug 2011

    Posted 10 Jun 2015 in reply to Kalin Link to this post

    Hi,

    I understand what you are saying, it's just a bit strange that the group headers were fine for all of the resources except for the last 2.

    I will keep trying to replicate my sizing issue in the sample project.

    Thanks

    Anthony

Back to Top
UI for WPF is Visual Studio 2017 Ready