Highlight days on WinRTXamlToolkit.Controls.Calendar

老子叫甜甜 提交于 2019-12-11 19:06:24

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!