DragItemThemeAnimation DragItemThemeAnimation DragItemThemeAnimation Class

Represents the preconfigured animation that applies to item elements being dragged.

Syntax

Declaration

public sealed class DragItemThemeAnimationpublic sealed class DragItemThemeAnimationPublic NotInheritable Class DragItemThemeAnimation
<DragItemThemeAnimation .../>

Inheritance Hierarchy

Inherited Members

Inherited properties

, , , , , , , , , , , , ,

Inherited methods

, , , , , ,

Inherited events

Remarks

Note that setting the Duration property has no effect on this object since the duration is preconfigured.

Examples

The following is an example of a drag-enabled custom control.


<!-- Example template of a drag-enabled custom control.  The 
     DragItemThemeAnimation will be run when the control
     is in the Dragging state.                     
-->
<ControlTemplate TargetType="local:DraggableControl">
    <Grid>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="DragStates">
                <VisualState x:Name="NotDragging"/>
                <VisualState x:Name="Dragging">
                    <Storyboard>
                        <DragItemThemeAnimation TargetName="contentRectangle"/>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Rectangle x:Name="contentRectangle" 
            Width="100" 
            Height="100" 
            Fill="{TemplateBinding Background}" 
 />
    </Grid>
</ControlTemplate>
public sealed class DraggableControl : Control
{
    public DraggableControl()
    {
        this.DefaultStyleKey = typeof(DraggableControl);
    }

    protected override void OnPointerPressed(PointerRoutedEventArgs e)
    {
        // Go to the Dragging state, which will start the DragItemThemeAnimation
        VisualStateManager.GoToState(this, "Dragging", true);
    }

    protected override void OnPointerReleased(PointerRoutedEventArgs e)
    {
        VisualStateManager.GoToState(this, "NotDragging", true);
    }

    protected override void OnPointerMoved(PointerRoutedEventArgs e)
    {
        // dragging implementation here
    }
}
// DraggableControl.h:
public ref class DraggableControl sealed : public Windows::UI::Xaml::Controls::Control
{
public:
    DraggableControl();
protected:
    virtual void OnPointerPressed(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) override;
    virtual void OnPointerReleased(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) override;
    virtual void OnPointerMoved(Windows::UI::Xaml::Input:: PointerRoutedEventArgs^ e) override;
};

// DraggableControl.cpp:
DraggableControl::DraggableControl()
{
    DefaultStyleKey = "MyApp.DraggableControl";
}

void DraggableControl::OnPointerPressed(PointerRoutedEventArgs^ e)
{
    // Go to the Dragging state, which will start the DragItemThemeAnimation
    VisualStateManager::GoToState(this, "Dragging", true);
}

void DraggableControl::OnPointerReleased(PointerRoutedEventArgs^ e)
{
    VisualStateManager::GoToState(this, "NotDragging", true);
}

void DraggableControl::OnPointerMoved(PointerRoutedEventArgs^ e)
{
    // dragging implementation here
}

Constructors summary

Initializes a new instance of the DragItemThemeAnimation class.

Properties summary

Gets or sets the reference name of the control element being targeted.

Identifies the TargetName dependency property.

Constructors

  • DragItemThemeAnimation()
    DragItemThemeAnimation()
    DragItemThemeAnimation()
    DragItemThemeAnimation()

    Initializes a new instance of the DragItemThemeAnimation class.

    public DragItemThemeAnimation()public New()Public Sub New()public DragItemThemeAnimation()

Properties

  • TargetName
    TargetName
    TargetName
    TargetName

    Gets or sets the reference name of the control element being targeted.

    public string TargetName { get; set; }public string TargetName { get; set; }Public ReadWrite Property TargetName As stringpublic string TargetName { get; set; }
    <DragItemThemeAnimation TargetName="nameString" />
    
    

    Property Value

    • string
      string
      string

      The reference name. This is typically the x:Name of the relevant element as declared in XAML.

  • TargetNameProperty
    TargetNameProperty
    TargetNameProperty
    TargetNameProperty

    Identifies the TargetName dependency property.

    public static DependencyProperty TargetNameProperty { get; }public static DependencyProperty TargetNameProperty { get; }Public Static ReadOnly Property TargetNameProperty As DependencyPropertypublic static DependencyProperty TargetNameProperty { get; }

    Property Value

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute

Details

Assembly

Windows.UI.Xaml.Media.Animation.dll