【问题标题】:Month cannot be altered in Silverlight DatePicker when custom CalendarStyle is specified指定自定义 CalendarStyle 时,无法在 Silverlight DatePicker 中更改月份
【发布时间】:2011-09-29 11:29:44
【问题描述】:

我采用了 DatePicker 并自定义了在平板电脑上使用的样式。我发现虽然可以选择日期,但无法更改月份。尽管应用了鼠标悬停样式,但单击上一个/下一个按钮或月份名称都没有任何影响。

按照 Mike Taulty 的建议,我采用了默认的日历样式并插入了一个 Viewbox 来增加大小: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}" BorderBrush="{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>

【问题讨论】:

    标签: silverlight calendar styles datepicker


    【解决方案1】:

    通过在可视化树中将 Viewbox 上移一级来修复,不知道为什么这里有错误但现在工作正常!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      • 2013-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多