自定义WinRT XAML工具包-日历控件

本文关键字:日历 控件 工具包 WinRT XAML 自定义 | 更新日期: 2023-09-27 17:59:30

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

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>

如何自定义此日历控件,例如FontWeight、Foreground、Background?

自定义WinRT XAML工具包-日历控件

如果绑定到模板部件属性的控件或模板没有公开属性,则可能需要更改模板。您可以在此处找到默认模板,日历部件的模板位于同一文件夹中:

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

你可能已经找到了答案,但我面临着类似的问题,并找到了解决方案,所以我想我会把它发布在这里,供其他面临类似难题的人使用。如果日历控件要离开页面,可以将其包装在Viewbox中,使其适合屏幕。我就是这样做到的。

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