I'm trying to paint a background of my WPF window using LinearGradientBrush, however my code doesn't work. Here is the code
LinearGradientBrush gradientBrush = new LinearGradientBrush( Color.FromArgb(0, 209, 227, 250), Color.FromArgb(0, 170, 199, 238), new Point(0.5, 0), new Point(0.5, 1));
Background = gradientBrush;
Unforunatelly my window is still white. Is it possible to change the Background color of the window using code behind ?
Background
will appear as black unless you haveAllowsTransparency
set to true. I guess you mean to use 255 instead of 0 for Alpha channel. If you try to set thatBackground
in the Windows constructor and you still can't see it, then it's because some other control in yourWindow
(probably aPanel
) has anotherBackground
set. Try to set it in aWindow
without any controls in it. – RolandorolandsonWindow
was stillWhite
. Probably should have posted an answer instead.. – Rolandorolandson