简体   繁体   中英

WPF RibbonWindow Minimize, Maximize / Restore, and Close Buttons Not Visible

So I've googled all day trying to find an answer and have come up short. I've found stuff close and maybe even found a solution and just didn't realized it but I cant seem to get the Minimize, Maximize / Restore, and Close buttons to show up (be visible) on my windows 10 machine. No one but myself and another developer who just got new laptops have this issue. I've tried changing my windows theme around and I did get them to show up with I turned some high contrast setting on but no luck otherwise. Despite not being visible they are there and functional because I can click in the area and see the window min, max, restore, close.

We are using .Net 4.0 and a RibbonWindow with a custom theme (BureauBlue.xaml). I'd like to believe it may have something to do with that but I don't know anything about it or where to start unfortunately.

在此处输入图片说明

<r:RibbonWindow x:Class="Ztools.Main" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                xmlns:props="clr-namespace:Ztools.Properties" 
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary" 
                IsTabStop="False" Icon="/Ztools;component/ztools32.ico" Height="830" Width="1200"                         WindowStartupLocation="CenterScreen" WindowState="Normal" 
                Loaded="RibbonWindow_Loaded" Closing="RibbonWindow_Closing"
                xmlns:my="clr-namespace:System;assembly=mscorlib" Title="Ztools 2.0" Name="mainRibbon"                   FontSize="14" SizeChanged="mainRibbon_SizeChanged"                                                       LocationChanged="mainRibbon_LocationChanged" 
                StateChanged="mainRibbon_StateChanged" Deactivated="mainRibbon_Deactivated"                               KeyUp="mainRibbon_KeyUp" Background="{x:Null}">
      <r:RibbonWindow.Resources>
          <ResourceDictionary>
              <ResourceDictionary.MergedDictionaries>
                  <ResourceDictionary Source="/Ztools;component/themes/bureaublue.xaml"/>
              </ResourceDictionary.MergedDictionaries>
          </ResourceDictionary>
      </r:RibbonWindow.Resources>
</r:RibbonWindow>

Another thing I noticed but haven't verified by pulling out my old laptop yet is I'm pretty sure the nice looking buttons showed up at design time as well and didn't look like this. 在此处输入图片说明

Bonus question/issue is sometimes when our computers go to sleep/hibernate go from docking station to no station (not sure which one or both) the theme bar will also randomly black out like this. If I could look at fixing this at the same time that would be great.

在此处输入图片说明 I did change it to a normal Window and was able to see all the buttons correctly but I guess I'd rather not go that route and know what the issue is and solve it.

Any thoughts ideas or suggestions are greatly appreciated.

Edit: So I don't think it has anything to do with the theme? I commented out everything having to do with the theme and they still don't show up... Not sure why I didn't take that simple step a long time ago.

The ribbonwindow in version 5 has set WindowStyle="none" by default.
Maybe the WindowStyle is just set to None?
Try set it to "SingleBorderWindow" its original default in the base class.

So going to post this again that way anyone with the same or similar issue can at least have an option to fixing their issue... since for some reason it was deleted despite containing valuable information as an alternative solution to the problem.

For now I changed it from a RibbonWindow to a Window an gave my Ribbon a margin of 0,-22,0,0 so things line up and look decent as suggested by a number of other SO posts. The buttons show up now, but aren't the RibbonWindow style so is what it is.

<Window x:Class="Ztools.Main" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                xmlns:props="clr-namespace:Ztools.Properties" 
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:r="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary" 
                IsTabStop="False" Icon="/Ztools;component/ztools32.ico" Height="830" Width="1200" WindowStartupLocation="CenterScreen" WindowState="Normal" 
                Loaded="RibbonWindow_Loaded" Closing="RibbonWindow_Closing"
                xmlns:my="clr-namespace:System;assembly=mscorlib" Title="Ztools 2.0" Name="mainRibbon" FontSize="14" SizeChanged="mainRibbon_SizeChanged" LocationChanged="mainRibbon_LocationChanged" StateChanged="mainRibbon_StateChanged" Deactivated="mainRibbon_Deactivated" KeyUp="mainRibbon_KeyUp">

   <r:Ribbon Title="Ztools 2.0 (Scale Configuration Editor)" IsTabStop="False" Background="#FFE5E5E5" FontSize="12" FontFamily="Arial" Margin="0,-22,0,0">
   </r:Ribbon>
</Window>

I not only had the same issue but was able to replicate it in a new project and fix it through this solution although for you it will require moving to a more recent .net version.

The problem seems to stem from using RibbonControlsLibrary. It's is an outdated version of the ribbon controls. As of .net 4.5 Ribbon is native to the framework and by removing the reference you'll be able to use the included RibbonWindow.

Move to a .net version 4.5+ and remove this reference

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

and use

<RibbonWindow> 

instead of

<r:RibbonWindow>

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