在winui 3 XAML中创建AnimatedIcon时出错

zkure5ic  于 2023-10-14  发布在  其他
关注(0)|答案(1)|浏览(92)

我按照文档,并希望添加一个动画按钮,VS建议我导入模块xmlns:animatedvisuals="using:ABI.Microsoft.Microsoft.UI.Xaml.Controls.AnimatedVisuals"
然而,在那之后,我得到了一个错误:XLS0504 The "Source" property does not support values of type "AnimatedFindVisualSource".
我的代码:

<?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>

会有什么错误呢?

kkbh8khc

kkbh8khc1#

而不是

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

使用

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

基本上,ABI命名空间是用于WinUI/WinAppSDK的内部使用。这个post应该解释得更好。

相关问题