WPF Calendar DisplayMode SelectionMode FirstDayOfWeek Start End BlackoutDates

//xaml
<Window x:Class="WpfApp427.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp427"
        mc:Ignorable="d"
        WindowState="Maximized"
        Title="MainWindow" Height="450" Width="800">
    <Window.Resources>
        <Style TargetType="Calendar">
            <Setter Property="IsTodayHighlighted" Value="True"/>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Calendar Grid.Row="0" Grid.Column="0" DisplayMode="Month" SelectionMode="SingleDate" FirstDayOfWeek="Monday"/>
        <Calendar Grid.Row="0" Grid.Column="1" DisplayMode="Year"  SelectionMode="SingleRange" FirstDayOfWeek="Sunday" />
        <Calendar Grid.Row="0" Grid.Column="2" DisplayMode="Decade" SelectionMode="MultipleRange" FirstDayOfWeek="Saturday"/>
        <Calendar Grid.Row="1" Grid.Column="0">
            <Calendar.BlackoutDates>
                <CalendarDateRange Start="9/1/2024" End="9/5/2024"/>
                <CalendarDateRange Start="9/10/2024" End="9/15/2024"/>
                <CalendarDateRange Start="9/20/2024" End="9/25/2024"/>
            </Calendar.BlackoutDates>
        </Calendar>
    </Grid>
</Window>

 

posted @ 2024-09-30 18:51  FredGrit  阅读(2)  评论(0编辑  收藏  举报