Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well, after lots of digging, many examples and Dodsky pointing me in the right direction. I figured it out and felt that sharing was the best way to repay the developer community. Since, I am new to XAML it is a small victory in project battle that I am in. Hopefully, it will help other newbies like me.</p> <p>I will try to explain the best way that I can to show you how to manipulate the calendar any way that you need to.</p> <p>In my UserControl</p> <pre><code>&lt;Calendar CalendarItemStyle="{DynamicResource calItemStyle}" Name="calJan" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" HorizontalAlignment="Center" VerticalAlignment="Center" OverridesDefaultStyle="False" IsEnabled="True" /&gt; </code></pre> <p>Some of the parameters are overkill, the main point is the Dynamic Resource</p> <pre><code>CalendarItemStyle="{DynamicResource calItemStyle}" </code></pre> <p>In my ResourceDictionary, I added the namespace</p> <pre><code>xmlns:primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=PresentationFramework" </code></pre> <p>You will also want to add the PresentationFramework reference to your project, if it is not already there.</p> <pre><code>&lt;Style x:Key="calItemStyle" TargetType="primitives:CalendarItem"&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="primitives:CalendarItem"&gt; &lt;ControlTemplate.Resources&gt; &lt;DataTemplate x:Key="DayTitleTemplate"&gt; &lt;TextBlock Text="{Binding}" HorizontalAlignment="Center" /&gt; &lt;/DataTemplate&gt; &lt;/ControlTemplate.Resources&gt; &lt;DockPanel Name="PART_Root" LastChildFill="True"&gt; &lt;Button x:Name="PART_PreviousButton" DockPanel.Dock="Left" Content="&amp;lt;" Focusable="False" Visibility="Hidden" /&gt; &lt;Button x:Name="PART_NextButton" DockPanel.Dock="Right" Content="&amp;gt;" Focusable="False" Visibility="Hidden" /&gt; &lt;Button x:Name="PART_HeaderButton" DockPanel.Dock="Top" FontWeight="Bold" Focusable="False" /&gt; &lt;Grid&gt; &lt;Grid x:Name="PART_MonthView" Visibility="Visible"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;/Grid&gt; &lt;Grid x:Name="PART_YearView" Visibility="Hidden"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;RowDefinition Height="Auto"/&gt; &lt;/Grid.RowDefinitions&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;/Grid&gt; &lt;/Grid&gt; &lt;Rectangle x:Name="PART_DisabledVisual" Opacity="0" Visibility="Collapsed" Fill="#A5FFFFFF"/&gt; &lt;/DockPanel&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsEnabled" Value="False"&gt; &lt;Setter TargetName="PART_DisabledVisual" Property="Visibility" Value="Visible" /&gt; &lt;/Trigger&gt; &lt;DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Calendar}}, Path=DisplayMode}" Value="Year"&gt; &lt;Setter TargetName="PART_MonthView" Property="Visibility" Value="Hidden" /&gt; &lt;Setter TargetName="PART_YearView" Property="Visibility" Value="Visible" /&gt; &lt;/DataTrigger&gt; &lt;DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Calendar}}, Path=DisplayMode}" Value="Decade"&gt; &lt;Setter TargetName="PART_MonthView" Property="Visibility" Value="Hidden" /&gt; &lt;Setter TargetName="PART_YearView" Property="Visibility" Value="Visible" /&gt; &lt;/DataTrigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>I chose to hide the Previous and Next buttons, just in case removal caused a problem with any events but otherwise, it does what I want it to and I can add or take away features as needed.</p> <p>Hope this helps others.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload