// Helper method that displays the markup of interest for // creating the specified brush. private static string GenerateLinearGradientBrushMarkup(LinearGradientBrush theBrush) { var sBuilder = new StringBuilder(); sBuilder.Append("<" + theBrush.GetType().Name + "\n" + " StartPoint=\"" + theBrush.StartPoint + "\"" + " EndPoint=\"" + theBrush.EndPoint + "\" \n" + " MappingMode=\"" + theBrush.MappingMode + "\"" + " SpreadMethod=\"" + theBrush.SpreadMethod + "\"\n" + " ColorInterpolationMode=\"" + theBrush.ColorInterpolationMode + "\"" + " Opacity=\"" + theBrush.Opacity.ToString(CultureInfo.InvariantCulture) + "\"" + ">\n"); foreach (var stop in theBrush.GradientStops) { sBuilder.Append ( " <GradientStop Offset=\"" + stop.Offset.ToString("F4") + "\" Color=\"" + stop.Color + "\" />\n" ); } sBuilder.Append("</LinearGradientBrush>"); return sBuilder.ToString(); }