WPF window border acting weird with Ribbon Control

妖精的绣舞 提交于 2019-12-01 07:20:02

问题


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

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


回答1:


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!




回答2:


I personally would, either play on margins, or better than that, investigate the style of that ribbon and change it the way it helps my needs



来源:https://stackoverflow.com/questions/21673967/wpf-window-border-acting-weird-with-ribbon-control

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