borderless wpf window behavior for .net 3.5 - c#

Does anyone know how to have a borderless wpf window in .Net 3.5?
Basically I am trying to have the same window as in mahapps metro but in .net 3.5. When I try to use the borderless behavior in the mentioned library, I get a thick dark border around right/bottom side of the window.
I want to avoid AllowsTransparency and use hook messages instead

Try setting the ResizeMove to NoResize or CanMinimize. This will remove the border.
NoResize or CanMinimize gets rid of the nice drop shadow effect and I don't want to loose the resizing (with grip).
In that case you should implement your own shadow (not so hard - just put everything inside one Border with desirable margin and set the DropShadowEffect). CanMinimize will still allow you to resize the window, but you must still implement your own resizing.

If you want to get rid of the border altogether, you have to set "WindowStyle" to "None" and the "ResizeMode" to "NoResize" or "CanMinimize".

Related

NavigationView Compact and Overlay

I`m exploring the navigationview control for uwp projects. I noticed that when I resize the window to a smaller size the menu changes to compact mode and, if the the window is small enough it overlays over the right page window rather than pushing it to the side.
I want to change the navigationview control to have this behavior by default without having to resize the window to a smaller size. The goal is to have the page window with the most space available possible.
I tried some properties but none worked, any pointers how to change this default behavior(Overlay and always in compact mode)?
you should use the latest NavigationView by winui library, and in this control you have a property PaneDisplayMode, explore values of this property and you can know what exactly you want. In your scenario you want the left pane to completely disappear and overlay then you can try LeftMinimal but if you want it in compact mode which shows only Icons then you can use LeftCompact
You can try to confugure the CompactModeThresholdWidth and ExpandedModeThresholdWidth properties of NavigationView. These properties will get or set the minimum window width at which the NavigationView enters Compact or Expanded display mode.
<NavigationView CompactModeThresholdWidth="280" ExpandedModeThresholdWidth="2800"/>
You can set the width value base on your requirement. For example, if you want the NavigationView alway in Compact Mode, you can use above code with any CompactModeThresholdWidth property value smaller than the minimum default UWP app window width and the ExpandedModeThresholdWidth property value larger than the maximum window width.

Translucent windows form

The look I'm going for is like
where the sidebar is semi-transparent and the background can be seen through. However TransparencyKey only takes into account the pixels at the top, if there is another panel on top that means that together they do not fit the transparency key then it will be opaque.
I have the TransparencyKey set to Fuchsia and the grapefruit sidebar is on top and is changed to sidebar.BackColor = Color.FromArgb(128,255,255,255); on load.
As you see the TransparencyKey only works on the top.
I have also tried setting the transparency on the form with undesired results.
How would I go about making the sidebar translucent?
Solution v
You just can't do that in winforms. Period. It's an antiquated technology that doesn't support "real" transparency. Whenever you see the word "transparent", it really means your control will inherit the back color of its parent. It does not mean you can see things that are behind it.
You may be able to do it with WPF, though I'm not entirely sure.
As noted by #JeremyThompson WPF is absolutely fine at doing this.
Inside the window include WindowStyle="None" AllowsTransparency="True" Background="Transparent" and then use panels/canvases as normal.

Aero borders cut off space from my WPF window

Unfortunately I can't provide screenshots for comparison now, since I'm unable to use Aero here at work, but I'm having the following problem:
I'm creating a small WPF application. My main window is not resizable, and the sizes and positions of everything inside are fixed. Everything works fine here using some pre-defined theme (it's "Windows Classic" most likely). Once I run the exe at home though - with Aero enabled - the border size is way bigger, but the actual total window size stays the same it seems to me. So the borders go "into" my window, shrinking the actual usable space and thus some of my controls are overlapped by the borders and it looks asymmetrical.
What can I do about this, if anything? Is there some option to make the borders be attached "outside" my used window space?
Edit: Here is an uploaded image of the Aero version. I hope the problem can be seen. (It's at the bottom)
In my opinion a static size is a bad way in wpf.
There are different solutions:
1. make your window a bit heigher or
2. reduce the margin between your used content elements or
2. use a dynamic size of your content. A grid with rowdefinitions set to "X*" where x is the height in propotion to total height of your content.
But im not sure ... you use a style in your app or is the style directly set into element? If you use a xaml stysle file, is it possible the style overrides your set position or margin properties?

Any descent WPF Custom Window Theme, no border transparent with resize on simulated borders?

I've been looking around for quite a while now and can't really find a complete example and may just be missing some small element.
I'm trying to create a WPF Theme/Style/ControlTemplate/etc for a WINDOW. The one where Window borders set to none, allow transparency, and background set to transparent. So, yes, this means I have to define the buttons, borders, background, etc as I've found in other samples.
I've found a few links that utilize (and have that working) through the use of a "Thumb" control anchored to the lower-right.
What I'm missing is how to do resize from the respective borders that are constructed within the new ControlTemplate of the theme. I do have the buttons working for things like min/max/restore/close, but can't quite get how to handle the resize.
Thanks
I've used this link once. If I remember well, the resize border could be set to work as an arbitrary amount of pixels from the sides of the Window, even without a "real" border element.
http://www.codeproject.com/Articles/131515/WPF-Custom-Chrome-Library

How to create a non OwnerDraw Button in .NET?

I'm creating a plugin to a software that skins the form I created. However, the button are not skin based on them and a standard gray button is shown. Asking on the software forum pointed me that .NET forms control are owner-draw and therefor my button won't redraw with the correct style instead of creating a non ownerdraw button.
All controls in the system.windows.forms namespace seem to be ownerdraw.
So how can I create a standar C++ PUSHBUTTON in .NET?
Currently codding in C# if that helps.
Thx
The controls in Windows.Forms are not owner-drawn, but rather system-drawn. This is how Windows paints them by default, be it a Button, TextBox or what else. You can override the drawing either by specifying that the control should be owner-drawn (that is: you are responsible for drawing it) - some controls support that, a couple of them even with a finer granularity (see ListView), or you can override the painting completely in OnPaint event of any Control descendant.
Your question is rather confusing - as I understand the buttons you create in your plug-in are not skinned. Obviously what you need is to tell this skinning framework to paint these buttons. There probably is or should be some component that you drop onto the plug-in form or method you call that will inject the skinning painting routines into your plug-in.
It sounds like you want to set the FlatStyle property of your button to FlatStyle.System. Windows Forms buttons are indeed, by default, owner draw at the WinAPI level, and are drawn by the framework.
Have you tried setting the FlatStyle to another value, such as Flat or Popup, just to see if that stops it being skinned?
also setting Flaststyle = Standard (as opposed to system) might solve your problem
Standard was the default and therefor wasn't reskinned. When setted to flat, I get a background color and a foreground color, but lose the round corner end the hover effect suggesting that the control is not reskinned and just color style is applyed. Flat is the only version not grey, but I lose some of button feature (hover, round corner)

Categories

Resources