wpf - Mahapps Metro 窗口标题在任务栏中不可见

标签 wpf xaml taskbar titlebar mahapps.metro

我正在使用 MahApp MetroWindow,它的标题模板如下所示。

<metro:MetroWindow x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:metro="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
    xmlns:local="clr-namespace:WpfApplication1">
<metro:MetroWindow.TitleTemplate>
    <DataTemplate>
        <Grid>
            <TextBlock Text="New Title"/>
        </Grid>
    </DataTemplate>
</metro:MetroWindow.TitleTemplate>

问题出现在任务栏中,它不显示标题。 enter image description here

最佳答案

将 Title 属性添加到窗口并在数据模板上进行模板绑定(bind)。尝试这个。

 <metro:MetroWindow x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:metro="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
    xmlns:local="clr-namespace:WpfApplication1"
Title="New Title">
<metro:MetroWindow.TitleTemplate>
    <DataTemplate>
        <Grid>
            <TextBlock Text="{TemplateBinding Content}"/>
        </Grid>
    </DataTemplate>
</metro:MetroWindow.TitleTemplate>

关于wpf - Mahapps Metro 窗口标题在任务栏中不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40024174/

相关文章:

c# - await 不会在原始上下文中恢复

c# - 跟踪在 MVVM 中选择了哪些按钮?

wpf - 在工具提示中添加断线

wpf - 父子数据网格在 MVVM 中具有不同的 ItemsSource

c# - 确定哪个文本框触发了文本更改事件

xaml - Xamarin Forms:如何为按钮添加填充?

c++ - C++ 任务栏中的闪烁/警报

c# - 将 WPF 应用程序添加到 Windows 任务栏

windows - 如何删除 Windows 任务栏中的多个 emacs 实例

c# - 将贝塞尔曲线段或线的端点绑定(bind)到 WPF 中的其他形状?