WPF Context Menu is not in Windows 10 Style - c#

I'm developing a simple WPF application. I don't use any custom styling. So it looks native on Windows 7 and 10. But today I have noticed that the context menu looks odd on Windows 10:
In other applications like 7-Zip, context menus look native:
How can I apply the flat Window 10 style to my context menus without breaking the native look on Windows 7?
Clarification: My context menu has a 3D split line on the left hand and a border around the selction. In 7-Zip, Explorer and other applications, there are neither a 3D split line nor a border around selctions. I'm used that WPF applications looks unlike Java Swing as a nativ Windows application.

But today I have noticed that the context menu looks odd on Windows 10:
Odd or not, this is actually how the default WPF ContextMenu looks like on Windows 10.
How can I apply the flat Window 10 style to my context menus without breaking the native look on Windows 7?
You need to define this "flat Window 10 style" yourself. There is an example of how to create a custom ContextMenu style available on MSDN that should get you started: https://msdn.microsoft.com/en-us/library/ms744758%28v=vs.110%29.aspx. There is no quick fix.

You're getting hung up on the shortcut keys (>, Enter, Ctrl + PgDn, etc). Your application isn't assigning any, while 7-zip is assigning them. Or maybe, the outlining. Don't get thrown off. Things are working exactly as they should.
But let's not overlook the fact that if 7-zip is not written in WPF, you can't expect the same results.

Related

Can you get the Windows 11 style menus/buttons etc... in WPF?

I am currently developing a small WPF application.
I have noticed that, especially in Windows 11, the Button and Menu controls look noticeably dated. Win 11 brought rounding to all of these, but WPF seems to be using an older, more square, styling:
Typical rounded button in a Win11 application vs. the default look of the <Button/> control in WPF:
This also applies to the <Menu /> - if we take a look at a typical program's menu UI styling under Windows 11 vs. the style in my WPF application:
Why does WPF have these different styles? I have been reading around and there's lots of mention about adding a reference to Microsoft.Windows.Common-Controls in app.manifest but this doesn't seem to have made any difference to these controls in my case.
What's more confusing is that the actual WPF window itself has rounded corners, and the context menu for right clicking the title bar of this window is using the new style - it seems to be controls inside the window that are plagued with the older styles.
Any help/info would be much appreciated!
WPF is officialy dead. That's probably the reason it doesn't receive new features, like the new theme (and more than 60 fps, stereoscopic rendering or native DirectX 12 without a picture buffer to transfer to DirectX 11 in WPF). Those other apps are using the Windows API for GUI, so they don't need to be even recompiled to get the new design. WPF is drawing GUI on its own, so it would need a not-so-small update, which is not economical.

Broken cursor in InkCanvas (WPF)

I created simple application with drawing canvas (InkCanvas) in C# WPF, which look like this (normal):
But when I run same application on VirtualMachine (Windows 10 in VirtualBox), cursor looks broken:
If I change appearance of cursor in Windows on VirtualMachine, broken cursor changes too:
The only similar case that resembles my problem, that I found, is this:
https://community.adobe.com/t5/acrobat-reader-discussions/mouse-pointer-corrupt/m-p/10300169
I updated Windows to latest version, but that didn't helped.
Would anyone know what the problem might be (drivers or some specific corrupted files in Windows)?
Edit 1:
Same in "Snip & Sketch" application - only as highlighter:

Inheriting default ComboBox to change border color or disable it

I'm working in a WinForms project.
I have a dark theme activated in Windows and this is a default combobox when it's focused:
And this is when it has no focus:
An horrible and insane white border appears when the control lost focus, I want to avoid that without disabling XP Styles in the project.
I know that maybe the only way is inheriting the control to make my own, the problem is I don't know what I need to do with the control, maybe changing a setstyle property or I don't know.
I think you're trying to solve a problem that isn't in the scope of your application. Isn't this just an issue with the theme in question you are using?
Windows has many themes. The major themes still supported are Classic (pre-XP), Luna (XP), Aero (Vista/Win7), and Modern (Windows 8). All of these can be customized to create an infinite number of possible scenarios.
Most Windows Forms controls are based on Win32 controls which are drawn by the OS according to these system themes.
So you have to understand that on the machine you're testing on what you're seeing is going to vary a lot from what users of the application will see on different versions of Windows with different user preferences.
The simple fact is that if you use WinForms base controls you really should surrender control of the appearance to the OS as much as possible.
It's also widely accepted to create your own application theme that the user can't change or that they have to pick from a predetermined set of themes you have created. Examples of this include Google Chrome, iTunes, Winamp, etc. It is typically an awful lot of work to do this with simple Win32 controls unless you use something like WPF which makes it easier.
The important thing is that you can't really pick and choose which parts of your application to theme. If you want it to look consistent you either take responsibility for the entire theme yourself or follow the Windows standards of using system resource colors such as ControlText, ActiveBorder, AppWorkspace, etc.

How can i find the order of the taskbar items in Windows 7?

I would like to establish what is the order of the taskbar items in Windows 7. The reason is that I would like to create an script (written in AutoHotkey or C#) that restore a set of icons to a previous determined order. I wan't to do this because any Virtual Desktop solutions for Windows forget the great and important point of keeping the taskbar item's order, i.e between desktop changes the order of the taskbar items are completely ignored and lost. The reason of why they ignore that fact is maybe because all of them rely in the HIDE/UNHIDE approach, they save what windows are active in any desktop and then between switches they Hide or UnHide the corresponding windows.
I already found a semi solution writted in QT/C++ (Location of app on the Windows 7 Taskbar) that base his function in find the left-upper pixel position of an item based in his color. I don't like that approach because the use of different themes or visual styles would break his functioning. I hope someone has another suggestion. This question differs from that in the link that I'm only interested in the order not in the exact pixel position of any button.
You may want to start with the Windows® API Code Pack for Microsoft® .NET Framework. This API allows you access to several Windows APIs (including certain taskbar functions) from managed code.
However, I'm not certain yet that it allows for functionality regarding the task bar in general vs. a specific application's taskbar entry. I will continue researching this and update if/when I find more information.

How can I write windows 7 desktop gadgets using c# & WPF?

I want to write a desktop gadget that will group icons on my desktop (using c# & WPF).
It will be a docked window that I can drag icons to it and they will stay their. Also there can be couple of this windows.
Where do I begin?
**I saw all the post here about it but I got lost. Please direct me to examples and explanation pages.
To expand on cevik's answer:
You cannot create WPF applications as gadgets BUT you have two options (which aren't as bad as you'd expect).
The reason is that widgets are composed mainly of web pages (HTML) and not executable (*.exe).
The problem of course is that WPF will only work with & produce executables.
First option - Windows API:
When I said you can't what I really meant is you can't use the Windows Vista/7 gadget platform to make your widgets.
However, you can always achieve a similar effect by using the Windows API.
The Windows API will let you do stuff to windows such as making them always on the background of other programs, which sounds to me like ~80% there (The rest would be stuff like making sure your window doesn't get re-sized or minimized, etc.).
Just as a note, the function you'd be looking for to make the window behind all other windows would be SetWindowPos (specifically the second parameter).
However make sure there isn't a library which already implements these stuff because it can be rather difficult (and consist of A LOT of surprises).
Second option - Silverlight
silverlight can be perceived as WPF for the web.
That obviously solves our problem.
However there is a cost to it, as expected.
Silverlight doesn't have all the features WPF has (possibly not all of the .NET framework as-well, not sure about that as I'm not really using it).
However it should be more than enough to get you by so you should definitely check it out.
Once you have your Silverlight application (and webpage) you'll have to create a manifest & install the gadget to your desktop. See here how to do so.
Maybe this will help you.
Template to easily get started on developing a Sideber Gadget using Silverlight 3.0 or 4.0 controls in C#.

Categories