-api-id | -api-type |
---|---|
P:Microsoft.UI.Xaml.Controls.AnimatedIcon.Source |
winrt property |
Gets or sets the animated visual shown by the AnimatedIcon
object.
This documentation applies to WinUI 2 for UWP (for WinUI in the Windows App SDK, see the Windows App SDK namespaces).
The animated visual shown by the AnimatedIcon
. The default is null
.
The Source
property does not support XAML attribute syntax (<AnimatedIcon Source="..."/>
); you have to set the Source
by using XAML property element syntax. However, Source
is defined as the control's content property, so you can omit the explicit <AnimatedIcon.Source>
tags. These XAML declarations produce the same result.
<!-- These XAML declarations produce the same result. -->
<muxc:AnimatedIcon>
<muxc:AnimatedIcon.Source>
<animatedvisuals:AnimatedBackVisualSource/>
</muxc:AnimatedIcon.Source>
</muxc:AnimatedIcon>
<muxc:AnimatedIcon>
<animatedvisuals:AnimatedBackVisualSource/>
</muxc:AnimatedIcon>
WinUI provides animated visuals for some common icons in the Microsoft.UI.Xaml.Controls.AnimatedVisuals namespace.
You can create custom animations to use as an animated icon in your app. Animations can be created with Adobe AfterEffects, then you can use that output with the Lottie-Windows library to generate a custom class that implements IAnimatedVisualSource2. You can use this class as the Source for an animated icon. For more information, see Use Lottie to create animated content for an AnimatedIcon.
Animated icon overview, AnimatedIcon, IAnimatedVisualSource.TryCreateAnimatedVisual, Microsoft.UI.Xaml.Controls.AnimatedVisuals
This example sets the AnimatedIcon.Source
property to AnimatedBackVisualSource.
<!--
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:animatedvisuals="using:Microsoft.UI.Xaml.Controls.AnimatedVisuals"
-->
<muxc:AnimatedIcon>
<animatedvisuals:AnimatedBackVisualSource/>
</muxc:AnimatedIcon>