namespace HelixToolkit { using System.Windows.Markup; using System.Windows.Media; /// /// Markupextension for LinearGradientBrush /// Usage: Background={helix:LinearGradientBrush Black,White} /// public class LinearGradientBrushExtension : MarkupExtension { private readonly LinearGradientBrush brush; /// /// Initializes a new instance of the class. /// /// The start color. /// The end color. /// The angle. public LinearGradientBrushExtension(Color startColor, Color endColor, double angle) { brush=new LinearGradientBrush(startColor,endColor,angle); } /// /// Initializes a new instance of the class. /// /// The start color. /// The end color. public LinearGradientBrushExtension(Color startColor, Color endColor) : this(startColor, endColor, 90) { } /// /// Returns the linear gradient brush. /// /// Object that can provide services for the markup extension. /// /// The brush to set on the property where the extension is applied. /// public override object ProvideValue(System.IServiceProvider serviceProvider) { return brush; } } }