c# - WinRT信息: Failed to assign to property '%0'

标签 c# wpf xaml windows-runtime

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

An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in RotateThemeAll.WindowsPhone.exe but was not handled in user code

WinRT information: Failed to assign to property '%0'. [Line: 28 Position: 31]

Additional information: The text associated with this error code could not be found.

到目前为止,我只编辑了 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>

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

最佳答案

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

关于c# - WinRT信息: Failed to assign to property '%0' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28026094/

相关文章:

wpf - 好的取消对话框 MVVM 模式 wpf。我该怎么做

WPF-XAML-C#-C++-如此困惑

c# - 如何在 WinRT XAML 中的值发生变化时为 TextBlock 设置动画?

c# - Kendo TabStrip 与 KendoGrid 内部使用 JavaScript 进行事件处理

Javascript 将 null 传递给 C# Controller 参数中的 ExpandoObject 字段

c# - 静态资源图像在运行时不出现(在设计时出现)

非焦点形式的 C#/WPF 热键(如 launchy)

wpf - 根据样式设置文本框文本格式

c# - 通过 lambda 表达式传递属性名称以读取属性值

xaml - 当我更改主题设置时,为什么我的 AdaptiveTrigger 会触发?