Window style with WPF Ribbon from Microsoft doesn't match Windows 8 style

半腔热情 提交于 2019-11-29 11:08:14

问题


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.

My code to create the ribbon:

<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>

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

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 (wich is displayed correctly in Windows 8).

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

Edit:

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...


回答1:


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).

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.

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.



来源:https://stackoverflow.com/questions/12511416/window-style-with-wpf-ribbon-from-microsoft-doesnt-match-windows-8-style

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!