Usually, you’ll define and use resources in your markup. However, if the need arises, you can
work with the resources collection in code. The most straightforward approach is to look up
the resource you need in the appropriate collection by name. For example, if you store a
LinearGradientBrush in the <UserControl.Resources> section with the key name ButtonFac
you could use code like this:
LinearGradientBrush brush = (LinearGradientBrush)this.Resources["ButtonFace"];
// Swap the color order.
Color color = brush.GradientStops[0].Color;
brush.GradientStops[0].Color = brush.GradientStops[2].Color;
brush.GradientStops[2].Color = color;