带有 Microsoft WPF Ribbon 的窗口样式与 Windows 8 样式不匹配 [英] Window style with WPF Ribbon from Microsoft doesn't match Windows 8 style

查看:34
本文介绍了带有 Microsoft WPF Ribbon 的窗口样式与 Windows 8 样式不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Windows 8 和 Visual Studio 2012 的发行版来创建带有功能区控件的 WPF 应用程序.我选择了.Net Framework 4.5中WPF自带的ribbon控件.

I'm using the release Version of Windows 8 and Visual Studio 2012 to create a WPF application with a Ribbon control. I choose the ribbon control that comes with WPF in .Net Framework 4.5.

我创建功能区的代码:

<RibbonWindow
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:WpfExperiments" x:Class="WpfExperiments.MainWindow"
    Title="MainWindow" Height="350" Width="525" Icon="Test.ico">
<Ribbon>        
    <Ribbon.ApplicationMenu>
        <RibbonApplicationMenu>
            <RibbonApplicationMenuItem Header="Item 1"></RibbonApplicationMenuItem>
        </RibbonApplicationMenu>
    </Ribbon.ApplicationMenu>
    <Ribbon.QuickAccessToolBar>
        <RibbonQuickAccessToolBar>
            <RibbonButton SmallImageSource="Test.ico" Label="Test"></RibbonButton>
        </RibbonQuickAccessToolBar>
    </Ribbon.QuickAccessToolBar>
</Ribbon>

但问题是它生成了一个丑陋的窗口,与windows 8的风格不符:

But the problem is that it generates a window with a ugly style that doesn't match the windows 8 style:

将其与资源管理器功能区进行比较.窗口标题居中(并具有不同的颜色)并且窗口的边框大小不同.功能区的样式不一样,但如果我的功能区样式与 MS Word 相同(在 Windows 8 中正确显示),我会很满意.

Compare it to the explorer ribbon. The window title is centered (and has a different color) and the border size of the window is different. The style of the ribbon isn't the same, but I would be satisfied if I had the same ribbon style as MS Word (which is displayed correctly in Windows 8).

WPF 的功能区控件不支持新的 Windows 8 样式吗?还是我错过了什么设置?

Does the ribbon control for WPF not support the new Windows 8 style? Or did I miss any setting?

我开始在 Blend 中编辑模板(4.0,我无法访问 5.0).修复了一些编译错误(似乎是blend中的错误)后,我可以运行该应用程序,但它看起来像这样:

I started to edit the template in Blend (4.0, i don't have access to 5.0). After fixing some compilation errors (seems to be bugs in blend), I can run the application, but it looks like this:

但这不是我改变的好起点...

But that isn't a good starting point for my changes...

推荐答案

WPF Ribbon 不是操作系统提供的控件的包装器(与大多数 Windows 窗体控件一样),而是从头开始构建以获得外观功能区开发时的感觉,同时它是一个与其他 WPF 控件一样灵活的控件(注意对模板部件的支持).

The WPF Ribbon isn't a wrapper for a control offered by the operating system (like most of the Windows Forms controls) but built from scratch to have the look and feel of the ribbon at the time it was developed while being a control that is as flexible as other WPF controls (notice the support for template parts).

也就是说,这是一个控件(当前)没有更新以支持 Windows 8 风格的问题.鉴于必须更改的多个控件的模板数量,以及向后兼容的需要(这是我目前的推测),当 .NET 4.5 发布时,它可能被视为不是优先事项.

That said, it's a matter of the control not (currently) being updated to support the Windows 8 style. Given the number of templates for multiple controls that would have to be changed, as well as the need to be backwards compatible (and this is my speculation at this point) it may have been seen as not a priority when .NET 4.5 was released.

您也许可以自己更改主题,但这看起来是一项艰巨的任务,因此使用已经实现 Windows 8 功能区样式的第三方控件对您来说可能是值得的.

You might be able to change the theme yourself, but that looks like a massive undertaking, so it might be worth it to you to use a third-party control which already implements the Windows 8 ribbon style.

这篇关于带有 Microsoft WPF Ribbon 的窗口样式与 Windows 8 样式不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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