2

我创建了一个 Xamarin.Forms 应用程序,它的名称很长。 当我在我的 4.5 英寸 Windows 10 手机上启动它时,它看起来很奇怪。

主页由 a 组成TabbedPage,它具有Title属性,但它没有FontSize属性。

在此处输入图像描述

Style我在我的 PCL 项目中使用以下内容:

 <Style TargetType="Label">     
        <Setter Property="TextColor" Value="{StaticResource BaseColor}" />
        <Setter Property="FontSize">
            <Setter.Value>
                <OnIdiom x:TypeArguments="x:Double"
                         Phone="18"
                         Tablet="28" />
            </Setter.Value>
        </Setter>
    </Style>

但是,如果我删除它,标题仍然很大。

我在哪里可以修改标题字体大小以使标题更小

更新

我检查了实时属性编辑器,它显示在Title里面CommandBar并且FontSize设置为 24。

在此处输入图像描述

我试图覆盖它的样式(在 XAML 和代码中),但它不起作用:

 <forms:WindowsPage.BottomAppBar>
        <CommandBar>
            <CommandBar.Style>
                <Style TargetType="CommandBar">
                    <Setter Property="FontSize" Value="4" />
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate>
                                <TextBlock Text="Whatever" />
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </CommandBar.Style>
            <CommandBar.Content>
                <TextBlock Text="Whatever" />
            </CommandBar.Content>
        </CommandBar>
    </forms:WindowsPage.BottomAppBar>



 public MainPage()
 {
  this.InitializeComponent();
  var bapp = BottomAppBar;
  LoadApplication(new MyXamarinApp.App(IoC.Get<SimpleContainer>()));
  BottomAppBar = bapp;
  BottomAppBar.FontSize = 4;
 }

任何想法?

更新 2:

您可以从这里下载示例项目。

4

1 回答 1

0

您必须覆盖其中一种内置样式:

 <!-- Tab title  -->
 <Style x:Key="TitleTextBlockStyle" TargetType="TextBlock">
    <Setter Property="FontSize" Value="18" />
    <Setter Property="TextWrapping" Value="NoWrap" />
    <Setter Property="TextTrimming" Value="CharacterEllipsis" />
 </Style>
于 2016-10-10T14:35:54.930 回答