I'm trying to play around with colors in WPF and the form's background color. Without doing ANYTHING ELSE (no code behind, deriving from another class, etc), I create a brand new default Windows Form. I change the background to some light blue color. Save the form. Run the program and open that form.. The form shows up in some other much darker color like it's not even respecting the XAML of
<Window x:Class="MyProjectNamespace.AnotherWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="AnotherWindow" Height="300" Width="300" Background="#4800A8A6">
<Grid>
</Grid>
</Window>
Additionally, if I try to take this same background value of #4800A8A6 and try to create a brush and do a BrushConverter.ConvertFrom( "#4800A8A6" );
and run the form, I STILL get the incorrect color as displayed via the designer... what gives...
The first byte of your color code, the '48' is an alpha value, so you're allowing alpha blending on your Window (not a "Windows Form" btw, that's a different technology ;) ), which means the color of your window is going to be blended with the colors of things behind it.
Try changing to: #FF00A8A6, see if that gives you a better result.
Your problem is the inclusion of an Alpha channel in the background color (i.e. #AARRGGBB). In the designer you're seeing the background being composited against whatever the background color is in VS (in my case White), which will "lighten" the background in comparison to when you run it as standalone.
To see this for yourself, try Background="#00A8A6", or you could try adding AllowsTransparency="True" (but this has an onerous requirement of WindowStyle.None).
That's probably because of the alpha component in your color. If you are trying to make your windows transparent, you have to use AllowsTransparency="True". If you don't, WPF will merge the default windows background color with your windows background.
Related
There are some problems and design of the transparent form:
1. I can not move form over an empty form-space
2. I can move the form by letters, but not even for the label
3. The text is distorted against a light background, if it is light.
4. The text is distorted on a dark background, if it is dark.
If you help, I attach the file with the corrected design, can anyone need it.
GDI+ only allows to mask one color and to smoothly render text, you need more than one color.
Is Windows Forms really necessary? You may want to switch to WPF, which supports full transparency.
I use metroframework GUI on Winform. I imported the files correctly. Other controls and properties are fine, but I found a problem, I couldn't change the background of a form to an Image file. I can see a small picture already imported at "Background Image" properties of a form. But the background is still white. Could someone please help? Thanks!
MetroForm I believe only has a Light and Dark Theme (White and Black). This can be changed under "Metro Appearance" > "Theme".
Then you can set a background image under "Metro Appearance" > "BackImage".
To have the image change with the Theme you would set "Metro Appearance" > "ApplyImageInvert" to true.
I don't think there's any option other than the Light or Dark Theme.
Hope this helps
EDIT:
To prove that you CAN add an image to the background using MetroFramwork and to negate the downvote.
Here are some screenshots:
Light:
Dark:
Settings:
In the properties menu set:
1. ApplyImageInvert to true
2. BackImage with your path
2. BackMaxSize to the size of your background image
Unfortunately, MetroForm doesn't support a background image. I suppose it's because that doesn't really fit into the Microsoft Design Language (Modern, Metro, whatever it officially is called).
The reason you're seeing BackgroundImage in the PropertyGrid, is because MetroForm is based on the Windows Forms Form control that supports background images. If you take a look at the MetroForm and MetroFormBase code, you can see that all the painting is overriden and there's not a single place where a background is drawn.
If you really want to have a background in your form, you can fork the project and implement it yourself. It's quite a small addition and shouldn't be much of a trouble.
Edit: To be clear, the original project, or one of the forks of the project don't have a capability to show background pictures on the form. It however seems that at least one of the forked projects do support Form background images using the BackImage property, as mentioned in ryantpayton's answer.
I'm attempting to extend a RichTextBox, so as to add some extra functionality; however, I'm running into a strange issue with the background color of my extended RTB. Here is the code:
RichTextBoxExtended.cs
public class RichTextBoxExtended: RichTextBox
{
// completely empty
}
MyView.xaml
<UserControl x:Class="MyNamespace.MyView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<RichTextBoxExtended />
</Grid>
</UserControl>
However, when showing this in a WPF page, the background color of the text box is gray, as if it were disabled (which it isn't, since I can still type into it fine). As a test, I replaced <RichTextBoxExtended /> in the XAML with <RichTextBox />, and that control is white as expected.
Does anyone know what could cause this issue? I can easily work around the problem by manually setting the background color to white, but am looking for a better solution.
I just copy paste your code to a test solution, place a frame in main window and put the RichTextBoxExtended in a page inside the frame, but the background of RTB is completely white. I think there is something else causing the problem.
this may be a pretty simple question.
I've created a VS Package and it has a nice little GUI. The background of the GUI should be System.Colors.ControlBrush:
<Grid Background="{x:Static SystemColors.ControlBrush}">
Now I have the problem, that it changes the color of the Grid, but not of the rest of the window. -> Screenshot
I thought I could change the background of the UserControl the same way, but somehow it doesn't work. Now it doesn't really look that great, if a part of the window is grey and the rest is white.
Any idea?
Your UserControl is probably not covering the entire window.
Remove any Width or Height attributes and make sure that the Horizontal/Vertical Alignments are both Stretch.
I'm using the DatePicker control from the WP7 SL toolkit. It navigates to DatePickerPage.xaml, which has the scrollers for date picking. I want to keep all the functionality, but change the colors. I'm messing around with DatePickerPage.xaml and updating colors to fit my needs.
I've been able to update the text colors on the scrollers and header, but I can't figure out how to update the background color on the selected item in each or the square outline while the scroller is active. Based on tests I have done with changing the background color of the DatePickerPage.xaml, it appears that the selected item and square outlines are an opaque version of the background color. Unfortunately, this wont work for me, since I want the background to the be white and the outlines aren't visible. Is there a way to explicitly set those colors?
If you get the control into Blend and right click on it and select Edit Tempate --> Edit a Copy, you'll get the template for the control so that you can edit it.
What you'll be looking for is the resources keys that are used for the background, foreground, etc. You can replace them with your own resources, or hardcode them, or the best option is to override the resource.
Additional Advice
Be careful though, don't forget that a user can have either a dark or light background to the phone, so unless your app is taking control of the background color of the whole page, you need to consider what might happen when picking colors