【问题标题】:Customise WinRT XAML Toolkit - Calendar Control自定义 WinRT XAML 工具包 - 日历控件
【发布时间】:2015-06-25 08:16:37
【问题描述】:

我编写了一个 Windows Phone 8.1 (WINRT) 应用程序。我需要在页面中显示日历。因此,我从 nuget 添加了 WinRT XAML 工具包 - 日历控件

PM> 安装包 WinRTXamlToolkit.Controls.Calendar

<Page
x:Class="DrFit.Pages.ActivityTimeTablePage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:DrFit.Pages"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:WinRT="using:WinRTXamlToolkit.Controls"
Background="Black">

    <Grid x:Name="LayoutRoot">       
        <WinRT:Calendar Height="500">

        </WinRT:Calendar>
    </Grid>
</Page>

如何自定义这个 Calendar 控件,例如 FontWeight,Foreground,Background?

【问题讨论】:

    标签: c# xaml windows-phone windows-phone-8.1 winrt-xaml-toolkit


    【解决方案1】:

    如果控件未公开属性或模板绑定到模板部件属性 - 您可能需要更改模板。您可以在同一文件夹中找到默认模板here 和日历部分的模板:

    WinRTXamlToolkit.Controls.Calendar/WinRTXamlToolkit.Controls.Calendar.Shared/Controls/Calendar

    【讨论】:

    • 我复制了这四个 xamls 并将它们用作 ResourceDictionaries。我自定义了days的字体颜色,但我还是有一些问题。日历控件超出手机右侧的边距。在哪里更改网格以便它根据页面/框架宽度自动调整?
    • 另一个问题,我想通过更改它们的边框颜色来突出显示一些日期(例如,假期)。我应该在 XAML 中将这种颜色更改带到哪里?突出显示的日期应与所选日期的颜色不同。 – 另外,请告诉我如何突出显示这些日期(例如,假期),使用哪种方法?
    【解决方案2】:

    您可能已经找到了答案,但我遇到了类似的问题并找到了解决方案,所以我想我会把它贴在这里,给遇到类似难题的其他人。如果日历控件超出页面,您可以将其包装在 Viewbox 中,使其适合屏幕。这就是我设法做到的。

    <Viewbox Stretch="Uniform">
        <Grid Height="600" Width="600">
            <toolkit:Calendar HorizontalAlignment="Center" VerticalAlignment="Center" Tapped="Calendar_Tapped"/>
        </Grid>
    </Viewbox>
    

    【讨论】:

      猜你喜欢
      • 2016-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多