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

Change CurrentVisibleRangeText

2 Answers 65 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Kieron
Top achievements
Rank 1
Kieron asked on 25 Jul 2016, 02:21 PM

Hi,

I want to apply a different CurrentVisibleRangeText dependant on what view definition the user is in.

So DayView would be in the format ddd dd\MM\yyyy

Timeline and MonthView would be dd\MM\yyyy - dd\MM\yyyy

So I've changed the CurrentInterval ContentControl to use VisibleRange instead of CurrentVisibleText :

<ContentControl x:Name="CurrentInterval"
      VerticalAlignment="Center"
      HorizontalAlignment="Right"
      Style="{StaticResource NavigationIntervalStyle}"
      Content="{TemplateBinding VisibleRange}"/>

Now how do I apply the NavigationIntervalStyle?  So far I have :

<Style x:Key="NavigationIntervalStyle" TargetType="ContentControl">
    <Setter Property="Margin" Value="5" />
    <Setter Property="VerticalAlignment" Value="Center" />
    <Setter Property="HorizontalAlignment" Value="Right" />
    <Setter Property="FontWeight" Value="Bold" />
    <Setter Property="ContentTemplate">
        <Setter.Value>
            <DataTemplate>
                <Grid>
                    <TextBlock Margin="0 1 0 0" Text="{Binding Path=Start, StringFormat={}{0:ddd dd/MM/yyyy}}" Foreground="White" />
                </Grid>
            </DataTemplate>
        </Setter.Value>
    </Setter>
</Style>

This works ok for DayView but obviously not giving me what I want for Timeline or MonthView - I would presume I would need another TextBlock linked to VisibleRange.End - but how to set the Visibility of this textbox so I don't get it in DayView?  Also would it be at all feasible for MonthView to run off the actual Month date and not just what is visible.. i.e. so it says 01/07/2016 - 31/07/2016 and not 27/07/2016 - 31/07/2016 (which is the actual VisibleRange of the month).

2 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 27 Jul 2016, 10:57 AM
Hello Kieron,

You could use a MultiValueConverter when binding the CurrentVisibleRangeText, so you can receive information on the active ViewDefinition and the VisibleRange and return inside the converter the value formatted per your requirement. Here is some sample code:

<ContentControl x:Name="CurrentInterval"
        VerticalAlignment="Center"
        HorizontalAlignment="Right"
        Style="{StaticResource NavigationIntervalStyle}">
    <ContentControl.Content>
        <MultiBinding Converter="{StaticResource CurrentVisibleRangeTextConverter}">
            <Binding Path="CurrentVisibleRangeText" RelativeSource="{RelativeSource TemplatedParent}" />
            <Binding Path="ActiveViewDefinition" RelativeSource="{RelativeSource TemplatedParent}" />
            <Binding Path="VisibleRange" RelativeSource="{RelativeSource TemplatedParent}" />
        </MultiBinding>
    </ContentControl.Content>
</ContentControl>

and the CurrentVisibleRangeTextConverter class:


public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
    var viewDef = values[1] as DayViewDefinition;
    if (viewDef != null && viewDef.VisibleDays == 1)
    {
        var currentVisibleRange = values[2] as DateSpan;
        if (currentVisibleRange != null)
            return currentVisibleRange.Start.ToString("d MMMM yyyy");
    }
    else
    {
        ...
    }
    return values[0];
}

I hope this will be helpful.

Regards,
Yana
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Kieron
Top achievements
Rank 1
answered on 27 Jul 2016, 12:19 PM
Perfect thanks.
Tags
ScheduleView
Asked by
Kieron
Top achievements
Rank 1
Answers by
Yana
Telerik team
Kieron
Top achievements
Rank 1
Share this question
or