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.
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>
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.
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>
Related
I'm working on a generic 'window control' as I find I do a lot of the same things in the desktop apps I work on. I have a small project with a control, designed to go in a window in another project. This worked fine when in different projects (but the same solution), but now I have moved the window control to a new solution and packed it into a nuget, then referenced the nuget in my project with the window.
On initialising the window, it complains it can't find a resource that the control uses. For theming, when the user sets a theme (and on startup) an image which will best suit the brightness of the theme colour is picked and applied to a UI bound BitmapImage property. This is the resource that the usage of the control in my window in another project can't find, I get this error:
To me it seems the application I am using the control in is trying to find the pngs in its own resources, rather than that of the nuget. But I'm unsure on how to ensure the nuget functions only internally.
The two images to pick from are both set as 'Resource' and not to copy to output. I have also tried solutions where the images are simply copied to the output and read in via a relative path, however this doesn't seem to work:
On setting the theme, this code runs:
ThemeImage = isThemeDark
? new BitmapImage(new Uri(#"pack://application:,,,/Images/Pallete_Light.png", UriKind.Absolute))
: new BitmapImage(new Uri(#"pack://application:,,,/Images/Pallete_Dark.png", UriKind.Absolute));
This works fine on a test window in the same project as the control, the little colour pallete icon is the on being picked from:
My window is very simple, and is the same as the window from the project where it works.
<Window
x:Class="SomeApplicationName.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SomeApplicationName" xmlns:win10themables="clr-namespace:Win10Themables;assembly=Win10Themables"
Title="SomeApplicationName"
Width="800"
Height="450"
AllowsTransparency="True"
Background="Transparent"
ResizeMode="NoResize"
WindowStyle="None"
WindowState="{Binding ElementName=WindowControl, Path=DataContext.WindowStateProperty, UpdateSourceTrigger=PropertyChanged}">
<win10themables:MainWindowControl x:Name="WindowControl" Title="SomeApplicationName" />
</Window>
In my App.xaml, I simply merge some resource dictionaries from the project the window control comes from so this project can use them:
<Application
x:Class="SomeApplicationName.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Win10Themables;component/ResourceDictionaries/Styles.xaml" />
<ResourceDictionary Source="/Win10Themables;component/ResourceDictionaries/Converters.xaml" />
<ResourceDictionary Source="/Win10Themables;component/ResourceDictionaries/Brushes.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
Sorry for the code dump. I'm at a bit of a loss on how to resolve this. I wanted to avoid repeatedly copying the base window project into each of my new projects, but at this point might be forced to do so anyway.
To anyone else who runs into this issue, I resolved this by keeping the images as resources, but then adding the images to a resource dictionary and merging that into the app.xaml of the project with the control, and referencing the image through Application.Current.Resource["ImageResourceName"] and casting to the type of my property (BitmapImage).
In my application where I consume this nuget (and add the control to the window), I also merge this resource dictionary into my app.xaml. This seems to resolve the issue, though I can't entirely understand the difference between referring it via the projects resources, and the resource dictionary, and why the latter resolves this. If anyone viewing this with this answer has any light to shed on this for mine and anyone elses benefit, please do!
If I create a new WPF application with a simple empty window like the code shown below, I find that all applications which are covered by the WPF app lost touch or stylus reaction. This can only be reproduced when Windows 10 is upgraded to 1803 (10.0.17134.0).
<Window x:Class="TheWPFCoveringWindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStyle="None" WindowState="Maximized"
AllowsTransparency="True" Background="Transparent"
Topmost="True">
<Button Content="Test" Width="200" Height="100" />
</Window>
I wrote another WPF application to find out what happened. So I add a StylusDown event to the Window like the code shown below:
// This code is in another WPF application.
private void OnStylusDown(object sender, StylusDownEventArgs e)
{
// Set a breakpoint here.
}
But the breakpoint never reached until I closed the transparent WPF window which is on top.
I pushed the very simple code to GitHub: dotnet-campus/TouchIssueOnWindows10.0.17134. Cloning it might help a little.
Why does this happen and how to solve it? Any reply is appreciated.
Updated
Microsoft has fixed this issue in .NET Framework August 2018 Preview of Quality Rollup.
August 30, 2018—KB4346783 (OS Build 17134.254)
Addresses an issue where touch and mouse events were handled differently in Windows Presentation Foundation (WPF) applications that have a transparent overlay window.
Original
After a whole week's debugging, I finally find out the solution.
Just add a ResizeMode="NoResize" property for the Window as the code shown below:
<Window x:Class="TheWPFCoveringWindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
WindowStyle="None" WindowState="Maximized"
AllowsTransparency="True" ResizeMode="NoResize"
Background="Transparent" Topmost="True">
<Button Content="Test" Width="200" Height="100" />
</Window>
#lindexi has posted this issue and this solution into his post. If you want more information about this issue, read win10 17025 touch bug - lindexi for more details. (This post is written in multiple languages, so you'll miss nothing even if you ignore the unknown characters.)
Actually, I still can't figure out why this property helps.
Could anyone explain the reason for this issue?
I'm updating a WPF in a project. As I received it, here is how the base window is specified:
<Window x:Class="SomeProject.ButtonForm"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SomeProject"
Title="ButtonForm" Height="647" Width="379" WindowStyle="None" ResizeMode="CanResizeWithGrip"
SnapsToDevicePixels="True" ShowInTaskbar="False" WindowStartupLocation="CenterScreen"
SizeChanged="Resized" Closing="Window_Closing" AllowsTransparency="True" >
Some main things are that WindowStyle is None, ResizeMode is CanResizeWithGrip and AllowsTransparency is True.
What I would like to do is make this window resizable from all four edges without grips. Is there a way to do this directly in the markup? I've seen some projects that implement this, but they involve whole separate files and complicated code-behind. Certainly there is a simpler way.
Check out MahApps.Metro. It may not be exactly what you're looking for, but it'll give your application an updated look with the functionality you're looking for and takes almost no effort.
You may also want to check out this question for some more discussion about custom window chrome.
You have to set ResizeMode to "CanResize" and AllowTransparency to "False" to be able to see the chrome to resize it.
I'm new to WPF programming and decided to give it a shot by trying out some ribbon control libraries.
The library that looks best for now is the Microsoft RibbonControlsLibrary. You can get it on the ribbon licensing page.
So far I've started a new project, added the control to the windows, but them I'm stuck: This is the code so far:
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="808" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" xmlns:my1="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary" WindowStyle="SingleBorderWindow">
<Grid>
<my1:Ribbon HorizontalAlignment="Left" Name="ribbon1" VerticalAlignment="Top" Height="165" Width="786" ShowQuickAccessToolbarOnTop="False" WindowIconVisibility="Visible" DataContext="{Binding}" Margin="0,-20,0,0">
<my1:Ribbon.ApplicationMenu>
<my1:RibbonApplicationMenu Visibility="Hidden" IsEnabled="True" />
</my1:Ribbon.ApplicationMenu>
<my1:RibbonTab Label="Tab1" Name="rtab1" >
</my1:RibbonTab>
<my1:RibbonTab Label="tab2" Name="rtab2"/>
</my1:Ribbon>
</Grid>
</Window>
Questions:
1) Where can I find samples for this ribbon control? I've tried googling, but came up with nothing useful.
2) How to add items to specific ribbon tabs? I'm lost in all these properties in the property grid. So far I havent found a designer for that purpose.
3) How can I switch the designer to show me what icons/button/... I placed on TabPage2?
(FYI: The fluent ribbon library does not seem to work for me, because I can't get rid of the ApplicationMenu.)
Found a great sample/tutorial:
http://windowsclient.net/downloads/folders/hands-on-labs/entry76491.aspx
The sample provides a manual with explanations and some test projects with step by step instructions to implement the ribbon control.
Though I'm totally new to WPF, I managed to extract necessary classes from the sample to provide a ribon based menu in my program.
I'm trying to use the ICSharpCode.AvalonEdit.TextEditor control from the SharpDevelop 4.0 project in a WPF app that I'm building, but I can't seem to get it to work.
I checked out a copy of the source code from svn://svnmirror.sharpdevelop.net/sharpdevelop/trunk/SharpDevelop/src/Libraries/AvalonEdit at revision 4304. Then, I built the project using Visual Studio 2008 SP1, which succeeded without errors.
I then created a blank new WPF project, added the build DLL to the toolbox and dropped the TextEditor control onto the default empty window, like so:
<Window x:Class="AvalonEditTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
Title="Window1" Height="300" Width="300" >
<Grid x:Name="LayoutRoot">
<avalonedit:TextEditor Name="textEditor" />
</Grid>
</Window>
However, when I run the project, the form comes up completely blank. No caret, the mouse cursor stays the default pointer, and the window does not respond to keypresses.
Am I missing something, or is AvalonEdit just a little broken?
[EDIT: I'm starting to think it might be related to my specific setup. I'm running the 64-bit Windows 7 RC. Might that have something to do with it? I've tried building it for x86 only, made no difference.]
Are you sure your namespace declaration is correct?
You can try something like this:
<Window x:Class="Editor.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300"
xmlns:e="clr-namespace:ICSharpCode.AvalonEdit;assembly=ICSharpCode.AvalonEdit">
<Grid>
<e:TextEditor x:Name="Editor" WordWrap="True" Height="200">
</e:TextEditor>
</Grid>
</Window>
I was able to get it to work without any issues.
The AvalonEdit TextEditor is just a view for a TextDocument model.
The problem was that a new AvalonEdit instance didn't start connected to any model instance, so there wasn't anything to edit.
The reason the code from statictype worked was that he didn't use <avalonedit:TextEditor/>, but <avalonedit:TextEditor></avalonedit:TextEditor>. This will assign an empty string to the Text property, which caused the editor to implicitly create a new document.
But this isn't relevant with recent AvalonEdit versions anymore, the editor will now always create a new TextDocument.
This works for me with the latest build
<DockPanel LastChildFill="True">
<avalonedit:TextEditor
HorizontalAlignment="Stretch"
Name="textEditor1"
VerticalAlignment="Stretch" />
</DockPanel>