开发者

Month cannot be altered in Silverlight DatePicker when custom CalendarStyle is specified

I've taken a DatePicker and customised the style for usage on a tablet. I'm finding that while days can be selected the month cannot be changed. Neither clicking the previous/next button or on the month name has any affect, although the mouseover style is applied.

I've taken the default Calendar style and inserted a Viewbox to increase the size, as suggested by Mike Taulty: http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2010/11/17/touched-part-5-touch-ready-controls.aspx

<Style TargetType="controls:Calendar" x:Key="TabletCalendar">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="controls:Calendar" xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows">
                <StackPanel x:Name="Root" HorizontalAlignment="Center" >
                    <Viewbox Width="480" Height="440">
                        <controlsPrimitives:CalendarItem x:Name="CalendarItem" Background="{TemplateBinding Background}" B开发者_开发技巧orderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" xmlns:controlsPrimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls" />
                    </Viewbox>
                </StackPanel>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

<Style TargetType="controls:DatePicker" x:Key="TabletDatePicker">
    <Setter Property="CalendarStyle" Value="{StaticResource TabletCalendar}" />
    .....
</Style>


Fixed by moving the Viewbox up a level in the visual tree, not sure why there was a fault here but is working fine now!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜