问题
I wrote a Windows Phone 8.1 (WINRT) App. I need to show Calendar in the page with Highlighted days like holiays. So, I added WinRT XAML Toolkit - Calendar Control from nuget.
PM> Install-Package 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" x:Name="ActivityCalender">
</WinRT:Calendar>
</Grid>
</Page>
I have two questions:
1: The calendar control goes out of margin on right side of phone. Where to change template so that it automatically adjusts according to page/frame width? I copied its four xamls and used these as ResourceDictionaries.
2: Another question, I want to highlight some dates (for example, Holidays) by changing the color of their borders. Where shall I bring this color change in XAML? Highlighted dates should be in different color than a selected date. – Also, please tell me how to highlight these dates (for example, Holidays), which method to use ? Highlighting a day removes the previously highlighted day.
ActivityCalender.SelectedDate = new DateTime(2015, 6, 21);
回答1:
Try to place calendar control inside a Viewbox control and it will automatically fit control according to the Viewbox control provided width & height.
<Viewbox Width="300" Height="300">
<WinRT:Calendar x:Name="ActivityCalender" Style="{StaticResource CalendarStyle2}" FontSize="36" FontWeight="Normal" Padding="0" CalendarDayButtonStyle="{StaticResource CalendarButtonCustom}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</Viewbox>
once done you can download the style code from the link below. Download Style code for WinRT XAML Tooklit Calendar Control - Windows Phone 8.1
and you will get the output link below image. You can also do customization in style.
来源:https://stackoverflow.com/questions/31108118/highlight-days-on-winrtxamltoolkit-controls-calendar