【问题标题】:WinRT information: Failed to assign to property '%0'WinRT 信息: 分配给属性“%0”失败
【发布时间】:2015-03-17 13:04:47
【问题描述】:

我对 xaml 非常陌生,当我尝试运行我的通用应用程序时出现此错误:

“Windows.UI.Xaml.Markup.XamlParseException”类型的异常 发生在 RotateThemeAll.WindowsPhone.exe 但未在 用户代码

WinRT 信息:未能分配给属性“%0”。 [行:28 位置:31]

附加信息:与此错误代码相关的文本可能 找不到。

到目前为止,我只编辑了 MainPage.xaml 文件(不是 c# 类),这是 xaml(非常简单)文件:

<Page
    x:Class="RotateThemeAll.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:RotateThemeAll"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">    

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="100" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <Image Grid.Row="0" Grid.Column="0" Source="Assets/spoon.gif" RenderTransformOrigin="0.5, 0.5">
            <Image.RenderTransform>
                <RotateTransform x:Name="AnimatedRotateTransform" Angle="0" />
            </Image.RenderTransform>

        </Image>
        <Button Grid.Row="1" Grid.Column="0" Content="Click">
            <Button.Triggers>
                <EventTrigger RoutedEvent="Button.Click">
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="AnimatedRotateTransform" 
                                                     Storyboard.TargetProperty="Angle" 
                                                     From="0"        
                                                     To="360" 
                                                     Duration="0:0:0.5" 
                                                     RepeatBehavior="Forever" />
                        </Storyboard>
                    </BeginStoryboard>
                </EventTrigger>
            </Button.Triggers>
        </Button>
    </Grid>
</Page>

我正在尝试在单击按钮后旋转图像。我知道这是一个著名的问题,但我不明白我错在哪里。谢谢你。

【问题讨论】:

  • 你能试试 VisualStateManager

标签: c# wpf xaml windows-runtime


【解决方案1】:

在 winrt 中 EventTrigger 将不支持其他事件,它仅适用于 加载的事件。检查此 link..因此它不适用于 RoutedEvent="Button.Click" .

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-08
    • 2022-01-09
    • 2021-03-02
    • 1970-01-01
    • 2020-05-23
    • 1970-01-01
    • 2021-08-30
    相关资源
    最近更新 更多