2017-10-01 14 views
0

J'ai créé une nouvelle application WPF dans Visual Studio 2017 pour Windows classique de bureau sous Windows 10.Créer ruban dans WPF App avec Visual Studio 2017 sous Windows 10

ajouter le ruban à la nouvelle application manière suivante . Le code XAML:

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

Et changer la classe de base:

public partial class MainWindow : RibbonWindow 
    { 
     public MainWindow() 
     { 
      InitializeComponent(); 
     } 
    } 

Mais la fenêtre d'application résultat semble laid:

enter image description here

Sur l'image ci-dessus, vous pouvez voir le Légende de l'explorateur (elle a une vue standard dans Windows10) et la légende de l'application créée (elle ressemble à la vue de style Windows98).

Pourquoi cela arrive-t-il et comment pourrait-il être réparé?

UPD1:

Lors de l'utilisation proposée ci-dessous référence à la System.Windows.Controls.Ribbon.dll la fenêtre principale ont des artefacts bleus sur les côtés gauche et RIGH: enter image description here

Aussi, quand je maximiser cette fenêtre - il y a bug apparaît avec la légende:

enter image description here

Le texte partitially coupé.

Répondre

0

Vous avez probablement ajouté un style basé sur un thème avec vos références r, r1 et r2. Je vous suggère de chercher un moyen de créer un ruban sans surcharger le style par défaut.

+0

Non, je crée juste une nouvelle solution WPF - et toute modification vous pouvez voir dans le premier post. – AeroSun

1

Ajouter une référence à System.Windows.Controls.Ribbon.dll et essayez ce balisage XAML:

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

Vous avez probablement pas besoin du 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> 
+0

1) À propos de vous première suggestion - regardez la mise à jour dans le premier message – AeroSun

+0

Quelle mise à jour? Vous ne devez pas utiliser RibbonControlsLibrary.dll. – mm8

+0

2) A propos de "vous n'avez probablement pas besoin de la RibbonWindow" - mais j'en ai besoin si j'utilise la fenêtre habituelle - il y a 2 légendes: d'abord - légende habituelle, ensuite - "légende ruban". – AeroSun