This looks good and will give it a try. If I'm able to get the value of the
gradientstops, then I could get the values of 1 and 4, and replace 2 and 3,
and with those, create a new LinearGradientBrush. either way may be fine.
Thanks for all the ideas.
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Thu, 03 Jul 2008 16:33:59 -0700, Peter Duniho
<Np*********@nnowslpianmk.comwrote:
[...]
I suppose it's possible you could just modify the individual GradientStop
instances in the original brush's GradientStops collection.
So I had a moment and decided to play with this a little. As near as I
can tell, the brush instance is completely mutable. So, if you've already
got a LinearGradientBrush assigned, you can just access individual
GradientStop instances from the GradientStops collection and modify them,
and the modification will be reflected immediately.
Even better, you don't even need to provide a new GradientStop. You can
just change the Color property of the GradientStop and it will work fine.
So, let's assume you've got an existing LinearGradientBrush, and you want
to change its color to match an existing SolidBrush (why you're not just
dealing directly with colors, I'm not sure...but that's what you said you
want to do, so okay... :) ). Then the code might look something like
this:
LinearGradientBrush brushTarget = /* initialized from the appropriate
control, user element, etc. */;
SolidColorBrush brushSource = /* initialized as desired...you said
from a color picker, for example */;
// Let's assume you want to change the color of the
// second pair of stops in the example you posted...
brushTarget.GradientStops[2].Color = brushSource.Color;
brushTarget.GradientStops[3].Color = brushSource.Color;
After that code, the two stops that were originally initialized to
#FF000000 will now have the new color assigned from the solid brush.
Hope that helps.
Pete