DrawingAttributes.PropertyDataChanged Event

Occurs when property data is added or removed from the StrokeCollection.

Namespace:  System.Windows.Ink
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public event PropertyDataChangedEventHandler PropertyDataChanged
<object PropertyDataChanged="PropertyDataChangedEventHandler" .../>

The following example is part of a custom stroke that can draw a three-dimensional effect. The stroke defines and stores a custom property called Shadowed, which belongs to DrawingAttributes. When the Shadowed property changes, the PropertyDataChanged event handler calls the OnInvalidated method, which causes the stroke to be redrawn.

class ShadowedStroke : Stroke
{

    // Be sure to pass in the DrawingAttributes when you create the stroke to 
    // subscribe to the PropertyDataChaned event. 
    public ShadowedStroke(StylusPointCollection stylusPoints, DrawingAttributes drawingAttributes)
        : base(stylusPoints, drawingAttributes)
    {
        this.DrawingAttributes.PropertyDataChanged += new PropertyDataChangedEventHandler(DrawingAttributes_PropertyDataChanged);
    }

    Guid shadow = new Guid("12345678-9012-3456-7890-123456789012");

    public bool Shadowed
    {
        // Return the value of the custom property, shadow. 
        // If there is no custom property, return false. 
        get
        {
            if (!this.DrawingAttributes.ContainsPropertyData(shadow))
            {
                return false;
            }

            object propertyData = this.DrawingAttributes.GetPropertyData(shadow);

            if (propertyData is bool)
            {
                return (bool)propertyData;
            }
            else
            {
                return false;
            }
        }

        // Set the value of the custom property. 
        set
        {
            this.DrawingAttributes.AddPropertyData(shadow, value);

        }
    }

    void DrawingAttributes_PropertyDataChanged(object sender, PropertyDataChangedEventArgs e)
    {
         this.OnInvalidated(new EventArgs());
    }

    protected override void DrawCore(System.Windows.Media.DrawingContext context, DrawingAttributes overrides)
    {
        // create a drop shadow 
        // 
        if (this.Shadowed)
        {
            Geometry pathGeometry = this.GetGeometry(overrides).Clone();
            pathGeometry.Transform = new TranslateTransform(5, 0);
            try
            {
                context.PushOpacity(0.5);
                context.DrawGeometry(Brushes.DarkGray, null, pathGeometry);
            }
            finally
            {
                context.Pop();
            }

        }
        base.DrawCore(context, overrides);
    }
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft