Sobreescribir los metadatos de una Dependency Property

        static StrokeToggleRectangle()
{
FillProperty.OverrideMetadata(typeof(StrokeToggleRectangle), new FrameworkPropertyMetadata(OnFillChanged));
}

#region Fill

/// <summary>
/// Handles changes to the Fill property.
/// </summary>
private static void OnFillChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var target = (StrokeToggleRectangle)d;
var oldFill = (Brush)e.OldValue;
Brush newFill = target.Fill;
target.OnFillChanged(oldFill, newFill);
}

/// <summary>
/// Provides derived classes an opportunity to handle changes to the Fill property.
/// </summary>
protected virtual void OnFillChanged(Brush oldFill, Brush newFill)
{
RecreatePen();
}

#endregion
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s