I've created a new WPF App in Visual Studio 2017 for Windows Classic Desktop on Windows 10.
I add the ribbon to new application in following way. The xaml code:
<r:RibbonWindow x:Class="AKnowledgeBase.MainWindow"
xmlns:r1="http://schemas.microsoft.com/winfx/2006/xaml/presentation/ribbon"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:AKnowledgeBase"
mc:Ignorable="d"
xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
xmlns:r2="clr-namespace:Microsoft.Windows.Controls.Ribbon.Primitives;assembly=RibbonControlsLibrary"
Title="AKnowledgeBase" Height="350" Width="525">
<DockPanel>
<r:Ribbon>
<r2:RibbonTabsPanel></r2:RibbonTabsPanel>
</r:Ribbon>
</DockPanel>
</r:RibbonWindow>
And change the base class:
public partial class MainWindow : RibbonWindow
{
public MainWindow()
{
InitializeComponent();
}
}
But the result application window looks ugly:
On the image above you can see the Explorer caption (it have standard view in Windows10) and the created application caption (it looks like Windows98-styled view).
Why it happens and how it could be fixed?
UPD1 :
When I use suggested below reference to the System.Windows.Controls.Ribbon.dll the main window have blue artifacts on left and righ sides:
Also when I maximize this window - there are appears bug with caption:
The text partitially cut.
Add a reference to System.Windows.Controls.Ribbon.dll
and try this XAML markup:
<RibbonWindow x:Class="AKnowledgeBase.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:r2="clr-namespace:System.Windows.Controls.Ribbon.Primitives;assembly=System.Windows.Controls.Ribbon"
mc:Ignorable="d"
Title="Window14" Height="300" Width="300">
<Grid>
<DockPanel>
<Ribbon>
<r2:RibbonTabsPanel></r2:RibbonTabsPanel>
</Ribbon>
</DockPanel>
</Grid>
</RibbonWindow>
You probably don't need the RibbonWindow
:
<Window x:Class="AKnowledgeBase.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApplication7"
xmlns:r2="clr-namespace:System.Windows.Controls.Ribbon.Primitives;assembly=System.Windows.Controls.Ribbon"
mc:Ignorable="d"
Title="Window14" Height="300" Width="300">
<Grid>
<DockPanel>
<Ribbon>
<r2:RibbonTabsPanel></r2:RibbonTabsPanel>
</Ribbon>
</DockPanel>
</Grid>
</Window>
You have probably added some theme based styling along with your r, r1 and r2 references. I'd suggest you look for a way to build Ribbon without overriding default styling.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.