如何增加在CalendarDatePicker上选择的日期的字体大小 [英] How to increase the font size of the date that is selected on a CalendarDatePicker

查看:158
本文介绍了如何增加在CalendarDatePicker上选择的日期的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的UWP应用中有一个 CalendarDatePicker 控件。我无法使用 FontSize 属性选择日期的字体大小。

I have a CalendarDatePicker control on my UWP app. I am not able to increase the size of the font of the date that is selected using the FontSize attribute.

如何在不覆盖很多样式的情况下轻松地做到这一点?

这是我拥有的基本代码:

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>

无论我设置的大小为 FontSize CalendarDatePicker 属性,所选日期的字体大小不会增加。

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

请帮助!

推荐答案

您可以使用Live Visual Tree工具检查控件的属性,在这种情况下,您想更改内部TextBlock的大小:

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


您可以在默认样式的副本中修改TextBlock字体大小le https://msdn.microsoft.com/en-us /library/windows/apps/mt299110.aspx

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

如您所见,它在默认模板中被硬编码为15:

As you can see, it is hardcoded 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" />

这篇关于如何增加在CalendarDatePicker上选择的日期的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆