C# 如何将现代UI菜单文本更改为大写

C# 如何将现代UI菜单文本更改为大写,c#,wpf,xaml,modern-ui,C#,Wpf,Xaml,Modern Ui,我正在使用WPF的现代UI创建一个项目。主菜单项似乎是小写的,这是我想改变的一个主题。有没有办法从我的项目的MainWindow.xaml或MainWindow.xaml.cs或任何其他文件更改它 我的菜单代码是: <mui:LinkGroup DisplayName="Home" > <mui:LinkGroup.Links> <mui:Link DisplayName="Dashboard" Source="/Pages/home.xam

我正在使用WPF的
现代UI
创建一个项目。主菜单项似乎是小写的,这是我想改变的一个主题。有没有办法从我的项目的
MainWindow.xaml
MainWindow.xaml.cs
或任何其他文件更改它

我的菜单代码是:

<mui:LinkGroup DisplayName="Home" >
    <mui:LinkGroup.Links>
        <mui:Link DisplayName="Dashboard" Source="/Pages/home.xaml" />
    </mui:LinkGroup.Links>
</mui:LinkGroup>

仅供参考,我可以从主题的代码中更改它,并构建一个新的
FirstFloor.ModernUI.dll
文件并使用它。但这不是我想要的,如果我在使用一个
.dll
后无法覆盖它,它将不会有效。一定有办法,我一定错过了

更新 我有一个显示窗口的图像


我对
仪表板
没有问题,但我想做的是将
home
改为大写,或者我如何在
xaml
代码上书写。

我遇到了与上述描述相同的问题

似乎是包含链接的
ModernMenu
DisplayName
值转换为小写

在Blend的帮助下,我发现基本的
ControlTemplate
包含一个
TextBlock
,它绑定到
DisplayNameProperty


为了解决这个问题,我基于基本的
现代菜单控制模板
现代菜单
创建了一个新的
控制模板
,但没有
绑定转换器
。 不幸的是,此解决方案不起作用,因为当我定义自定义
ControlTemplate
时,整个控件不可见或没有绘制

在我看来,目前没有办法轻松地更改
DisplayNameProperty
样式。。我花了很多时间寻找解决问题的方法,但每次尝试都失败了

可能从
ModernMenu
继承的自定义控件和基于
ModernMenu
的新
ControlTemplate
将无法使用该转换器


我将在接下来的几天内对其进行测试,并发布我在该尝试中的经验。

如果您查看MUI项目的源代码,就会发现一个名为ModernMenu.xaml的主题(在FirstFloor.ModernUI项目的主题下)

您可以简单地向自己的应用程序添加样式,如下所示。(我删除了将文本设置为小写的转换器,并增加了第一行菜单选项之间的间距,以便将包含多个单词的选项与相邻选项清楚地分开。)


这应该就够了。

你说的小写是什么意思。。你不提供标题的文本吗?你是说Home显示为Home,Dashboard显示为Dashboard吗?是的,我也这么说,我确实提供了
DisplayName
,但它总是以小写形式显示它这似乎是
链接中的某个东西,它将所有内容都小写。您需要创建一个
自定义控件
,该控件将从
链接
控件继承。然后,您可以覆盖或隐藏
DisplayName
依赖项属性。我同意Mike的观点,您应该查看链接内部并搜索DisplayName。看看是谁设置的。你能不能公开控件的样式模板来查看该绑定,看看它是否不像从模板中的绑定基础上拉出转换器那么简单?比如是否有一个保存xaml模板的ModernUI.xaml资源字典?如何更改LinkGroup的样式。Links?对我来说不起作用。我应该把这个放在哪里?我在主窗口上添加了样式,但什么也没发生。
<Style TargetType="controls:ModernMenu">
    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="controls:ModernMenu">
                <Grid>
                    <Grid.Resources>
                        <Style TargetType="ListBox" BasedOn="{StaticResource {x:Type ListBox}}">
                            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden"/>
                            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden"/>
                            <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                            <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
                        </Style>
                    </Grid.Resources>

                    <Grid.RowDefinitions>
                        <RowDefinition Height="40" />
                        <RowDefinition Height="16" />
                    </Grid.RowDefinitions>

                    <ListBox ItemsSource="{TemplateBinding VisibleLinkGroups}"
                     SelectedItem="{Binding SelectedLinkGroup, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}">
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="ListBoxItem">
                                <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                                <Setter Property="FontFamily" Value="Segoe UI Light" />
                                <Setter Property="Foreground" Value="{DynamicResource MenuText}" />
                                <Setter Property="FontSize" Value="23"/>
                                <Setter Property="HorizontalContentAlignment" Value="Center" />
                                <Setter Property="VerticalContentAlignment" Value="Center" />
                                <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
                                <Setter Property="Margin" Value="0,0,25,0" />
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="ListBoxItem">
                                            <TextBlock DataContext="{TemplateBinding Content}"
                                               Text="{Binding DisplayName}"
                                               HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                               VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                               SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="true">
                                                    <Setter Property="Foreground" Value="{DynamicResource MenuTextHover}"/>
                                                </Trigger>
                                                <Trigger Property="IsSelected" Value="true">
                                                    <Setter Property="Foreground" Value="{DynamicResource MenuTextSelected}"/>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ListBox.ItemContainerStyle>
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                    </ListBox>

                    <ListBox Grid.Row="1"
                     ItemsSource="{Binding SelectedLinkGroup.Links, RelativeSource={RelativeSource TemplatedParent}}"
                     SelectedItem="{Binding SelectedLink, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
                     VerticalAlignment="Top">
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="ListBoxItem">
                                <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                                <Setter Property="FontFamily" Value="Segoe UI" />
                                <Setter Property="Foreground" Value="{DynamicResource SubMenuText}" />
                                <Setter Property="FontSize" Value="11"/>
                                <Setter Property="Margin" Value="0,0,12,0" />
                                <Setter Property="HorizontalContentAlignment" Value="Center" />
                                <Setter Property="VerticalContentAlignment" Value="Center" />
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="ListBoxItem">
                                            <Grid DataContext="{TemplateBinding Content}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                                                <TextBlock Text="{Binding DisplayName, Converter={StaticResource ToUpperConverter}}" TextAlignment="Center"/>
                                                <TextBlock Text="{Binding DisplayName, Converter={StaticResource ToUpperConverter}}" FontWeight="Bold" Visibility="Hidden" />
                                            </Grid>

                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="true">
                                                    <Setter Property="Foreground" Value="{DynamicResource SubMenuTextHover}"/>
                                                </Trigger>
                                                <Trigger Property="IsSelected" Value="true">
                                                    <Setter Property="Foreground" Value="{DynamicResource SubMenuTextSelected}"/>
                                                    <Setter Property="FontWeight" Value="Bold" />
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ListBox.ItemContainerStyle>
                        <ListBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel Orientation="Horizontal" />
                            </ItemsPanelTemplate>
                        </ListBox.ItemsPanel>
                    </ListBox>
                </Grid>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
xmlns:controls="clr-namespace:FirstFloor.ModernUI.Windows.Controls;assembly=FirstFloor.ModernUI"