Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

c# - 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="ImagesSmallIcon.png">
                    <r:RibbonApplicationMenuItem Header="Exit"
                                                      x:Name="MenuItemExit"
                                                      ImageSource="ImagesExit.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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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) : enter image description here

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...