简体   繁体   中英

WPF window border acting weird with Ribbon Control

I am using the Ribbon control in WPF and I noticed there are 2 different versions.

  1. using Microsoft.Windows.Controls.Ribbon;

    • If I use this one in my xaml and class, my whole window will be in a very old windows style.
  2. using System.Windows.Controls.Ribbon;

    • If I use this one in my xaml and class, my Ribbontabs suddenly won't fill correctly anymore.

When I use both of them. With this:

<ribbon:RibbonWindow x:Class="WPSDashboard.Views.ShellWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ribbon="clr-namespace:System.Windows.Controls.Ribbon;assembly=System.Windows.Controls.Ribbon"
        xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary" 
        xmlns:prism="clr-namespace:Microsoft.Practices.Prism.Regions;assembly=Microsoft.Practices.Prism" 
        Title="WPSDashboard"
        x:Name="RibbonWindow"
        Width="640" Height="480">


    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Ribbon Region -->
        <r:Ribbon x:Name="Ribbon" prism:RegionManager.RegionName="RibbonRegion">
            <r:Ribbon.ApplicationMenu>
                <r:RibbonApplicationMenu SmallImageSource="Images\SmallIcon.png">
                    <r:RibbonApplicationMenuItem Header="Exit"
                                                      x:Name="MenuItemExit"
                                                      ImageSource="Images\Exit.png"
                                                      Command="{Binding ExitCommand}"/>
                    </r:RibbonApplicationMenu>
            </r:Ribbon.ApplicationMenu>
        </r:Ribbon>

        <Grid x:Name="ClientArea" Grid.Row="1">                   

            <!-- Workspace Region-->
            <GridSplitter HorizontalAlignment="Left" Width="2" Grid.Column="1"/>
            <ContentControl x:Name="WorkspaceRegion" Grid.Column="1" prism:RegionManager.RegionName="WorkspaceRegion" />
        </Grid>

    </Grid>
    </ribbon:RibbonWindow>

My Ribbontabs will load but the window now looks like this: I can't click on close and minimize and maximize. <---

Screenshot

How can I get the border to be normal instead of small?
I can't close my windows this way.

I found the best way to make it look and work good!

Instead of the tags <ribbon:RibbonWindow on the beginning of the xaml, Make it <Window .
Also add this part:

xmlns:r="clr-namespace:System.Windows.Controls.Ribbon;assembly=System.Windows.Controls.Ribbon"

Then in your class delete your : RibbonWindow (If it's there)

If that doesn't work and you don't need the quick access toolbar, this may help: Go back to your XAML, and change the Ribbon margin to -22 :

 <r:Ribbon x:Name="Ribbon" prism:RegionManager.RegionName="RibbonRegion" Margin="0,-22,0,0" >

Now my application looks like this(with the -22 margin) : 在此输入图像描述

Now it looks like a normal application without an ugly windows 98 or 2000 style and the close button, minizime button and maximize button are back!

我个人会,或者利用边缘,或者更好,调查那个功能区的风格,并改变它的方式来帮助我的需要

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM