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

How to remove leading 0 from single digits dates in month view?

4 Answers 93 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Kjell
Top achievements
Rank 1
Kjell asked on 21 Nov 2011, 05:27 AM
For example 01 should be 1, 02 should be 2, etc (this was default behavior on the scheduler).  I assume this can be done in a custom style template.  I am already using one so I think if you can just tell me which part to edit then it should be pretty easy.  Thank in advance.

4 Answers, 1 is accepted

Sort by
0
Dani
Telerik team
answered on 21 Nov 2011, 12:14 PM
Hi Kjell,

To change the string format of the month view time ruler item, you do not need a style selector. It will be more convenient for you to use the TimeRulerItemTemplateSelector . I copy here the templates of the selector for your convenience.

<telerik:TimeRulerItemTemplateSelector x:Key="TimeRulerItemTemplateSelector">
    <telerik:TimeRulerItemTemplateSelector.HorizontalDayMajorItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FormattedValue}" Margin="2" />
        </DataTemplate>
    </telerik:TimeRulerItemTemplateSelector.HorizontalDayMajorItemTemplate>
    <telerik:TimeRulerItemTemplateSelector.HorizontalDayMinorItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FormattedValue}" Margin="2" />
        </DataTemplate>
    </telerik:TimeRulerItemTemplateSelector.HorizontalDayMinorItemTemplate>
    <telerik:TimeRulerItemTemplateSelector.HorizontalWeekMajorItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FormattedValue}" Margin="2" />
        </DataTemplate>
    </telerik:TimeRulerItemTemplateSelector.HorizontalWeekMajorItemTemplate>
    <telerik:TimeRulerItemTemplateSelector.HorizontalWeekMinorItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FormattedValue}" Margin="2" />
        </DataTemplate>
    </telerik:TimeRulerItemTemplateSelector.HorizontalWeekMinorItemTemplate>
    <telerik:TimeRulerItemTemplateSelector.VerticalDayMajorItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FormattedValue}" Margin="0 2" MinWidth="54" TextAlignment="Right" />
        </DataTemplate>
    </telerik:TimeRulerItemTemplateSelector.VerticalDayMajorItemTemplate>
    <telerik:TimeRulerItemTemplateSelector.VerticalDayMinorItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FormattedValue}" Margin="0 2" MinWidth="54" TextAlignment="Right" />
        </DataTemplate>
    </telerik:TimeRulerItemTemplateSelector.VerticalDayMinorItemTemplate>
    <telerik:TimeRulerItemTemplateSelector.VerticalWeekMajorItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FormattedValue}" Margin="0 2" MinWidth="54" TextAlignment="Right" />
        </DataTemplate>
    </telerik:TimeRulerItemTemplateSelector.VerticalWeekMajorItemTemplate>
    <telerik:TimeRulerItemTemplateSelector.VerticalWeekMinorItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FormattedValue}" Margin="0 2" MinWidth="54" TextAlignment="Right" />
        </DataTemplate>
    </telerik:TimeRulerItemTemplateSelector.VerticalWeekMinorItemTemplate>
    <telerik:TimeRulerItemTemplateSelector.HorizontalTimelineGroupTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FormattedValue}" Margin="2 1" TextAlignment="Left" />
        </DataTemplate>
    </telerik:TimeRulerItemTemplateSelector.HorizontalTimelineGroupTemplate>
    <telerik:TimeRulerItemTemplateSelector.HorizontalTimelineMajorItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FormattedValue}" Margin="2" TextAlignment="Left" />
        </DataTemplate>
    </telerik:TimeRulerItemTemplateSelector.HorizontalTimelineMajorItemTemplate>
    <telerik:TimeRulerItemTemplateSelector.HorizontalTimelineMinorItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FormattedValue}" Margin="2" TextAlignment="Left" />
        </DataTemplate>
    </telerik:TimeRulerItemTemplateSelector.HorizontalTimelineMinorItemTemplate>
    <telerik:TimeRulerItemTemplateSelector.VerticalTimelineGroupTemplate>
        <DataTemplate>
            <telerikPrimitives:LayoutTransformControl VerticalAlignment="Top">
                <telerikPrimitives:LayoutTransformControl.LayoutTransform>
                    <RotateTransform Angle="-90" />
                </telerikPrimitives:LayoutTransformControl.LayoutTransform>
                <TextBlock Text="{Binding FormattedValue}" Margin="2 1" Height="16" TextAlignment="Right" />
            </telerikPrimitives:LayoutTransformControl>
        </DataTemplate>
    </telerik:TimeRulerItemTemplateSelector.VerticalTimelineGroupTemplate>
    <telerik:TimeRulerItemTemplateSelector.VerticalTimelineMajorItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FormattedValue}" Margin="0 2" MinWidth="54" TextAlignment="Right" />
        </DataTemplate>
    </telerik:TimeRulerItemTemplateSelector.VerticalTimelineMajorItemTemplate>
    <telerik:TimeRulerItemTemplateSelector.VerticalTimelineMinorItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FormattedValue}" Margin="0 2" MinWidth="54" TextAlignment="Right" />
        </DataTemplate>
    </telerik:TimeRulerItemTemplateSelector.VerticalTimelineMinorItemTemplate>
    <telerik:TimeRulerItemTemplateSelector.MonthGroupTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FormattedValue}" Margin="6 2" />
        </DataTemplate>
    </telerik:TimeRulerItemTemplateSelector.MonthGroupTemplate>
    <telerik:TimeRulerItemTemplateSelector.MonthItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding FormattedValue}" Margin="6 2" />
        </DataTemplate>
    </telerik:TimeRulerItemTemplateSelector.MonthItemTemplate>
</telerik:TimeRulerItemTemplateSelector>

The last template, MonthItemTemplate, is the one you need. Simply replace the binding with any string formatting specifier you wish.

I hope this helps.

Regards,
Dani
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Kjell
Top achievements
Rank 1
answered on 21 Nov 2011, 05:09 PM
Thank you, sorry for being dense but can you be more specific with the example.  I tried sticking a formatter in there but it is not working.  For example here is one of the things I tried (I got this from the documentation):

 

<TextBlock Text="{Binding FormattedValue, StringFormat=d}" Margin="6 2" />

I know it's the rigth spot because I can wipe the text out but I can't get it to format.  What am I doing wrong?

0
Dani
Telerik team
answered on 22 Nov 2011, 10:07 AM
Hi Kjell,

Please, accept my apologies for the misguiding information. Actually, the DateTime value in the MonthItemTemplate is already formatted and you would use the template selector for customization purposes only.

To format the DateTime value, you should use a property of the MonthView definition called TimerulerMajorTickStringFormat. Please, consider the following example:

<telerik:MonthViewDefinition TimerulerMajorTickStringFormat="{}{0:%d}" />

I hope this helps.

Kind regards,
Dani
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Kjell
Top achievements
Rank 1
answered on 22 Nov 2011, 10:28 AM
Worked perfectly, thank you.
Tags
ScheduleView
Asked by
Kjell
Top achievements
Rank 1
Answers by
Dani
Telerik team
Kjell
Top achievements
Rank 1
Share this question
or