Try this...
var brush = new LinearGradientBrush(new GradientStopCollection(
new GradientStop[] { new GradientStop(Colors.Blue, 2.0), new GradientStop(Colors.Red, 3.0) }));
using (var outfile = File.CreateText("Brush.xaml"))
{
XamlWriter.Save(brush, outfile);
}
Which produces the following:
<LinearGradientBrush xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#FF0000FF" Offset="2" />
<GradientStop Color="#FFFF0000" Offset="3" />
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>