wpf Mahapps - 如何在标题中设置适当的大小写

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20595209/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 10:13:02  来源:igfitidea点击:

Mahapps - How to set Proper Case in Titles

.netwpfmahapps.metro

提问by Lalitya

I am using Mahapps and I am not able to set Proper case for Window titles and Group box titles etc..

我正在使用 Mahapps,但无法为窗口标题和组框标题等设置适当的大小写。

I tried googling and Typography settings.

我尝试了谷歌搜索和排版设置。

If someone knows out there could you please help-me here..

如果有人知道那里可以请你帮我在这里..

Thanks

谢谢

回答by Marcos

To set window title case:

设置窗口标题大小写:

Set the TitleCapsproperty on your MetroWindowto false.

TitleCaps您的属性设置MetroWindowfalse.

<controls:MetroWindow x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    TitleCaps="False" />

To use title case in groupbox:

要在 groupbox 中使用标题大小写:

Put that TextBlockin the GroupBox's header.

把它TextBlock放在GroupBox的标题中。

<GroupBox>
    <GroupBox.Header>
        <TextBlock Text="My Group Box"/>
    </GroupBox.Header>
    Some content
</GroupBox>

回答by Suplanus

TitleCaps="False"is obsolete, use this code in the Window:

TitleCaps="False"已过时,请在窗口中使用此代码:

TitleCharacterCasing="Normal"

回答by Oscar Vicente Perez

Completing @Marcos answer:

完成@Marcos 回答:

There are better options than change the Header directly, without losing the Style and Bindings

有比直接更改标题更好的选择,而不会丢失样式和绑定

I had the same problem 2 years after so i'll post my solution. I had to read the code at Git Hub so i realized that the MetroGroupBox Style uses a DependencyProperty in ControlsHelper class named 'ContentCharacterCasing' so we have 2 options, set an style or set the property directly in the control. But before, you need this xmlns in the xaml:

2 年后我遇到了同样的问题,所以我会发布我的解决方案。我不得不阅读 Git Hub 上的代码,所以我意识到 MetroGroupBox 样式在名为“ContentCharacterCasing”的 ControlsHelper 类中使用 DependencyProperty,因此我们有 2 个选项,设置样式或直接在控件中设置属性。但在此之前,您需要在 xaml 中使用此 xmlns:

'xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"'

Style Option:

样式选项:

<Style TargetType="{x:Type GroupBox}" BasedOn="{StaticResource MetroGroupBox}">
    <Setter Property="Controls:ControlsHelper.ContentCharacterCasing" Value="Normal" />
</Style>

Control Property Option:

控制属性选项:

<GroupBox Margin="20,20,20,0" Grid.Row="0" Header="Cliente" Controls:ControlsHelper.ContentCharacterCasing="Normal" />

回答by Pieter Geerkens

The following call returns "Fred Jones". I just tested it in a C# program by adding a reference to the assembly Microsoft.VisualBasic.dll:

以下调用返回“Fred Jones”。我刚刚通过添加对程序集Microsoft.VisualBasic.dll的引用在 C# 程序中对其进行了测试:

Microsoft.VisualBasic.Strings.StrConv(
    "fred jones",
    Microsoft.VisualBasic.VbStrConv.ProperCase
)