How do I put shadows on objects in c# windows form? - c#

I have a top navigation bar which is a panel. I set the BackColor of it to white. And I want it to cast a shadow so that it would be less pale though it would look simple and minimal. However, I do not know how do I do that other than putting borders to it.

Related

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.

WP8.1 Opaque hidden AppBar/CommandBar

How do I achieve opaque CommandBar/AppBar while it's hidden in WP8.1? CommandBar's property Opacity works just fine, but only when AppBar is opened. Though even then you can see non-opaque rectangle at the bottom. I want my AppBar to be opaque at all times, even when ClosedDisplayMode is set to Minimal.
[UPDATED]
"This happens because when you create a CommandBar an automatic margin is created for the ContentGrid to free a space below it for the app bar. Give the Main Grid a bottom margin by -24 and your content will show behind the command bar Like this: Margin="0,0,0,-24"
[ORIGINAL COMMENT]
I guess it is not applicable to do it with the control itself. But the workaround is to give it an opaque color. You can give the command bar a color but reduce its alpha value that controls the color's transparency.
Example: that's the Color code of the "Red" color with 80% transparency: #CCFF0000

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

ToolStrip TextBox Colour

I have set up a ToolStrip in my C# WinForms project and have added a TextBox on it. I'm just curious whether it is normal that the TextBox is barely visible due to the colour of the ToolStrip and TextBox.
I could put a border around it or change the background colour of the TextBox but that just looks odd.
Is there some property which I haven't thought of which I could set to make it stand out more but not look out of place?
Screenshot added:
A very light border would probably be best. if you use the same color as the toolstrip, you won't really notice the border at the bottom, but it will make the top of the search box stand out. you might also want to add a margin around it, or less padding inside of it, so it doesn't fill up the whole hight.

Semi-transparent panel background

I have a panel which sits on top of a control that renders video. I have controls (buttons, etc), on that panel which I want to be fully opaque. Now, creating a transparent panel background is doable, by overriding the CreateParams property. However, how to I make a panel with a semi-transparent (~50% opacity) background, while keeping the buttons fully opaque?
I am using .NET 2.0.
In the end it turned out that this isn't possible really, setting transparency on a panel is pretty rubbish in WinForms.
The workaround I used was to render the controls manually onto the given surface, and alter the alpha values appropriately.
You could use two panels, one placed within the other. The outer panel has no background, and hosts the inner panel and the controls, and the inner panel, whose Z-Index places it behind the controls, provides the semi-transparent background.
I'll admit that I'm suggesting this without actually verifying that this will work...

Categories

Resources