Interaction.Triggers在设计时导致"XamlParseException" [英] Interaction.Triggers causing 'XamlParseException' at design time

查看:33
本文介绍了Interaction.Triggers在设计时导致"XamlParseException"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

还有其他人遇到这个问题吗?我正在使用Visual Stuido 2015 Prof.,当我在ItemsControl.ItemTemplate中使用Interaction.Triggers时,设计器将抛出以下异常:

Did anyone else encounter this problem? I am using Visual Stuido 2015 Prof. and when I use Interaction.Triggers in an ItemsControl.ItemTemplate the designer throws following exeption:

'XamlParseException: Collection property 'System.Windows.Controls.AnyControl'.'Triggers' is null.'

(AnyControl:如果我将触发器放置在Image中,则为Image等.)

(AnyControl: If I put the trigger inside an Image, it's Image etc.)

程序在运行时按预期运行,没有任何问题.

The program is´running as expected at runtime without any problems.

这有点烦人,因为每次我想查看设计器视图时,我都必须评论/取消对触发器的注释.

That's a little annoying since I have to comment/uncomment the triggers everytime when I want to see the designer view.

示例代码段部分:

<Grid>
    <ItemsControl ItemsSource="{Binding Currencies}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Grid Margin="3,3,20,3">

                    <StackPanel Grid.Column="0" Margin="0,0,2,0" VerticalAlignment="Center" Background="Transparent">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="MouseEnter">
                                <i:InvokeCommandAction Command="{Binding DataContext.MouseEnterCommand, RelativeSource={RelativeSource AncestorType=Window}}" 
                                                           CommandParameter="{Binding .}" />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>

                        <Image Width="50" Height="50"
                               Source="{Binding Settings.ActiveImage}" ToolTipService.ShowDuration="30000">

推荐答案

这是Visual Studio 2015的问题.我已升级到Visual Studio 2017,并且可以正常工作.

It was an issue with Visual Studio 2015. I upgraded to Visual Studio 2017 and it's working.

这篇关于Interaction.Triggers在设计时导致"XamlParseException"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆