xamlwinui-3winuiwindows-app-sdk

Error when creating AnimatedIcon in WinUI 3 XAML


I followed the documentation and wanted to add an animated button, VS suggested me to import module xmlns:animatedvisuals="using:ABI.Microsoft.Microsoft.UI.Xaml.Controls.AnimatedVisuals"

However, after that I get an error: XLS0504 The "Source" property does not support values of type "AnimatedFindVisualSource".

My code:

<?xml version="1.0" encoding="utf-8"?>
<Window
    x:Class="MyApp.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:MyApp"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:animatedvisuals="using:ABI.Microsoft.UI.Xaml.Controls.AnimatedVisuals"
    mc:Ignorable="d"
    Activated="Window_Activated">

    <Grid>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
            <Button x:Name="myButton" Click="myButton_Click">Click Me</Button>

            <Button PointerEntered="Button_PointerEntered" PointerExited="Button_PointerExited" Width="75">
                <AnimatedIcon x:Name="SearchAnimatedIcon">
                    <AnimatedIcon.Source>
                        <animatedvisuals:AnimatedFindVisualSource/>
                    </AnimatedIcon.Source>
                    <AnimatedIcon.FallbackIconSource>
                        <SymbolIconSource Symbol="Find"/>
                    </AnimatedIcon.FallbackIconSource>
                </AnimatedIcon>
            </Button>
        </StackPanel>
    </Grid>
</Window>

What could be the error?


Solution

  • Instead of

    xmlns:animatedvisuals="using:ABI.Microsoft.UI.Xaml.Controls.AnimatedVisuals"
    

    use

    xmlns:animatedvisuals="using:Microsoft.UI.Xaml.Controls.AnimatedVisuals"
    

    Basically, the ABI namespace is for internal use of WinUI/WinAppSDK. This post should explain it better.