Share via


DragItemThemeAnimation Classe

Définition

Représente l’animation préconfigurée qui s’applique aux éléments déplacés par glissement.

public ref class DragItemThemeAnimation sealed : Timeline
/// [Windows.Foundation.Metadata.Activatable(65536, "Microsoft.UI.Xaml.WinUIContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.WinUIContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class DragItemThemeAnimation final : Timeline
[Windows.Foundation.Metadata.Activatable(65536, "Microsoft.UI.Xaml.WinUIContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class DragItemThemeAnimation : Timeline
Public NotInheritable Class DragItemThemeAnimation
Inherits Timeline
<DragItemThemeAnimation .../>
Héritage
Object Platform::Object IInspectable DependencyObject Timeline DragItemThemeAnimation
Attributs

Exemples

Voici un exemple de contrôle personnalisé avec glissement.

// Themes/Generic.xaml
<!-- Example template of a drag-enabled custom control. The
     DragItemThemeAnimation will be run when the control
     is in the Dragging state, and reverted when it isn't.
-->
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:BlankApp1">

    <Style TargetType="local:DraggableControl" >
        <Setter Property="Template">
            <Setter.Value>
                <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>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
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
struct DraggableControl : DraggableControlT<DraggableControl>
{
    DraggableControl(){ DefaultStyleKey(winrt::box_value(L"MyApp.DraggableControl")); }

    void OnPointerPressed(Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e);
    void OnPointerReleased(Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e);
    void OnPointerMoved(Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e);
};

// DraggableControl.cpp
void DraggableControl::OnPointerPressed(Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e)
{
    // Go to the Dragging state, which will start the DragItemThemeAnimation.
    Windows::UI::Xaml::VisualStateManager::GoToState(*this, L"Dragging", true);
}

void DraggableControl::OnPointerReleased(Windows::UI::Xaml::Input::PointerRoutedEventArgs const& e)
{
    Windows::UI::Xaml::VisualStateManager::GoToState(*this, L"NotDragging", true);
}

void DraggableControl::OnPointerMoved(Windows::UI::Xaml::Input::PointerRoutedEventArgs const& 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
}

Remarques

Notez que la définition de la propriété Duration n’a aucun effet sur cet objet, car la durée est préconfigurée.

Constructeurs

DragItemThemeAnimation()

Initialise une nouvelle instance de la classe DragItemThemeAnimation.

Propriétés

AutoReverse

Obtient ou définit une valeur qui indique si la chronologie est lue en sens inverse après avoir effectué une itération vers l’avant.

(Hérité de Timeline)
BeginTime

Obtient ou définit l’heure à laquelle cette chronologie doit commencer.

(Hérité de Timeline)
Dispatcher

Retourne null toujours dans une application SDK d'application Windows. Utilisez DispatcherQueue à la place.

(Hérité de DependencyObject)
DispatcherQueue

Obtient le DispatcherQueue auquel cet objet est associé. DispatcherQueue représente une installation qui peut accéder au DependencyObject sur le thread d’interface utilisateur, même si le code est initié par un thread autre que l’interface utilisateur.

(Hérité de DependencyObject)
Duration

Obtient ou définit la durée de cette chronologie, sans prendre en compte les répétitions.

(Hérité de Timeline)
FillBehavior

Obtient ou définit une valeur qui spécifie le comportement de l’animation une fois qu’elle a atteint la fin de sa période active.

(Hérité de Timeline)
RepeatBehavior

Obtient ou définit le comportement à répétition de cette chronologie.

(Hérité de Timeline)
SpeedRatio

Obtient ou définit le taux, par rapport à son parent, auquel le moment progresse pour cette chronologie.

(Hérité de Timeline)
TargetName

Obtient ou définit le nom de référence de l’élément de contrôle ciblé.

TargetNameProperty

Identifie la propriété de dépendance TargetName .

Méthodes

ClearValue(DependencyProperty)

Efface la valeur locale d’une propriété de dépendance.

(Hérité de DependencyObject)
GetAnimationBaseValue(DependencyProperty)

Retourne toute valeur de base établie pour une propriété de dépendance, qui s’applique dans les cas où une animation n’est pas active.

(Hérité de DependencyObject)
GetValue(DependencyProperty)

Retourne la valeur effective actuelle d’une propriété de dépendance à partir d’un objet DependencyObject.

(Hérité de DependencyObject)
ReadLocalValue(DependencyProperty)

Retourne la valeur locale d’une propriété de dépendance, si une valeur locale est définie.

(Hérité de DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)

Inscrit une fonction de notification pour écouter les modifications apportées à un DependencyProperty spécifique sur ce instance DependencyObject.

(Hérité de DependencyObject)
SetValue(DependencyProperty, Object)

Définit la valeur locale d’une propriété de dépendance sur un DependencyObject.

(Hérité de DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty, Int64)

Annule une notification de modification précédemment inscrite en appelant RegisterPropertyChangedCallback.

(Hérité de DependencyObject)

Événements

Completed

Se produit lorsque l’objet Storyboard a terminé la lecture.

(Hérité de Timeline)

S’applique à

Voir aussi