Questions tagged [brushes]
47 questions
31
votes
2 answers
Using a StaticResource SolidColorBrush to define the Gradient Stop Colors
I am creating some wpf resource dictionaries with all the styles for an application! I have a few LinearGradientBrushes, where the color is set directly in the LinearGradientBrush reference as GradientStops. However, I want to have a predefined set…

code-zoop
- 7,312
- 8
- 47
- 56
28
votes
7 answers
Pick a Random Brush
I'm looking for a method to pick a random Brush in Brushes collection (Aqua,Azure, ...Black,...). Any clue?

ojsim
- 457
- 2
- 6
- 7
22
votes
4 answers
Setting background of panel with custom color code
In WPF,I can set the background of a stack panel using the below code
stackPanelFlasher.Background = Brushes.Aqua;
How can I set the color as a hex color code for example #C7DFFC?

Shyju
- 214,206
- 104
- 411
- 497
8
votes
3 answers
Linear Gradient Brush Fade WPF
I have a brush that colors the background of a header. I like the way the brush looks but would like it to fade to transparent in the bottom third. Any ideas how to do this?

Andrew Boes
- 2,013
- 4
- 22
- 29
8
votes
2 answers
Brushes.White slows graphics demo down
Below is a (very naive) implementation of Conway's Game of Life in WPF. It's just a demo...
xaml:

dharmatech
- 8,979
- 8
- 42
- 88
7
votes
1 answer
Why doesn't this WPF code generate a context menu?
Perhaps I'm having a Post-Ballmer-Peak Moment.
I'm hoping that someone can help point out the obvious to me.
Why does this code generate a context menu on right click:

corey broderick
- 185
- 2
- 7
6
votes
2 answers
Is there a "Pens" class to complement "Brushes" and "Colors" in WPF?
There isn't one called Pens, that's for sure, but it's too odd not to find it. Is it really absent, or am I being blind?
(I'm just looking for a convenience class - for example, Colors.Red and Brushes.Red is there, but for pens the shortest appears…

Roman Starkov
- 59,298
- 38
- 251
- 324
6
votes
2 answers
Is rendering a lot of repeated images more or less performant than using brushes in WPF?
An application our company is working on currently displays many rectangle shapes with gradients to draw 'Tiles'. An internal discussion came about that posed a question of performance. These tiles are about 100 pixels by 200 pixels, and are either…

Kilhoffer
- 32,375
- 22
- 97
- 124
6
votes
1 answer
how can i fill the transparent area of the image when my finger moved on
I wanna draw the transparent area with brush, but my code work not very well.I think someone can help me here. My code :
// Handles the start of a touch
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
CGRect bounds = [self…

bencore
- 61
- 1
5
votes
1 answer
Apply Opacity to LinearGradientBrush
I have a LinearGradientBrush defined as follows. I want to use this somewhere in my xaml but I want to change the opacity in this particular case (only in this instance, not everywhere I use it). Any ideas how to accomplish this?
…

KrisTrip
- 4,943
- 12
- 55
- 74
5
votes
4 answers
Programmatically get a brush from the Brushes class?
I have a property that allows the string name of a known colour to be sent to my control. The property only accepts proper known colour names, like "Red" or "Blue"
private KnownColor _UseColor = KnownColor.Red;
///
/// Gets or…

jcharlesworthuk
- 1,079
- 8
- 16
4
votes
1 answer
Setting borderbrush to LinearGradientBrush in WPF
I'm new to WPF and still having some basic problems.
I have a control from devcomponents that defaults to a blue border. My textboxes etc. have a more grey colour. I want the devcomponents control to have the same border.
I look in the properties…

Peter S
- 191
- 1
- 2
- 10
3
votes
3 answers
Window background color: appears darker than specified?
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…

DRapp
- 47,638
- 12
- 72
- 142
3
votes
2 answers
Animation change from LinearGradientBrush to SolidColorBrush
Is it possible with an animation to change the Ellipse.Fill from a LinearGradientBrush to a SolidColorBrush or change the gradientStops within the LinearGradientBrush?

Johan Alkstål
- 5,225
- 9
- 36
- 48
3
votes
4 answers
Using multiple brushes within a single GeometryDrawing in WPF
Is it possible to use multiple brushes within a single GeometryDrawing? I have several geometries that I want to draw with different brushes, and it's rather verbose to have to declare an individual GeometryDrawing for each. I'm looking for a more…

sourcenouveau
- 29,356
- 35
- 146
- 243