How to increase the font size of the date selected in CalendarDatePicker

I have a CalendarDatePicker control in my UWP application. I cannot increase the font size of the date selected using the FontSize attribute.

How can I do this without overriding many styles?

Here is the basic code I have:

 <Page x:Class="CalendarPickerExample.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:CalendarPickerExample" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"> <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> <CalendarDatePicker FontSize="30" /> </Grid> </Page> 

No matter what size I set the FontSize attribute to CalendarDatePicker , the font size of the selected date does not increase.

FontSize on CalendarDatePicker

Please, help!

0
source share
2 answers

You can check the properties of the control using the Live Visual Tree tool, in your case you want to resize the internal TextBlock:

Living visual tree Live property explorer

You can change the font size of the TextBlock in the default style copy https://msdn.microsoft.com/en-us/library/windows/apps/mt299110.aspx

As you can see, it is hard-coded to 15 in the default template:

 <TextBlock x:Name="DateText" HorizontalAlignment="Left" Foreground="{ThemeResource SystemControlForegroundBaseMediumBrush}" Text="{TemplateBinding PlaceholderText}" Grid.Row="1" FontSize="15" Padding="12, 0, 0, 2" VerticalAlignment="Center" /> 
+1
source

You can use the Visual Tree Extensions from the UWP community toolkit to capture a text box control by name or type and change its FontSize property:

  <CalendarDatePicker x:Name="Calender"/> 

-

  Calender.FindDescendantByName("DateText").FontSize = 30; 
+1
source

Source: https://habr.com/ru/post/1275529/


All Articles