【发布时间】:2014-10-06 10:50:48
【问题描述】:
大家好,我正在尝试在列表框的项目中实现点击效果,但我不断收到此错误:
找不到类型“cmd:EventToCommand”。确认您没有丢失程序集引用,并且所有引用的程序集都已构建。
<catel:UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:catel="http://catel.codeplex.com"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:cmd="http://www.galasoft.ch/mvvmlight"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
以及我尝试实现 on click 方法的代码:
<Grid>
<ItemsControl ItemsSource="{Binding Source={StaticResource cvsRoutes}}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Expander Header="{Binding Name}" MinHeight="50">
<ListBox>
<i:Interaction.Triggers>
<i:EventTrigger EventName="PreviewMouseLeftButtonDown">
<cmd:EventToCommand Command="{Binding PreviewMouseLeftButtonDownCommand}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<TextBlock Text="Something" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="KeyUp">
<cmd:EventToCommand Command="{Binding KeyUpCommand}" PassEventArgsToCommand="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBlock>
<TextBlock Text="Something" />
<TextBlock Text="Something" />
<TextBlock Text="Something" />
<TextBlock Text="Something" />
</ListBox>
</Expander>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
你能告诉我是什么问题吗?我该如何解决?
【问题讨论】:
-
是 Catel 的 EventToCommand 部分吗?我认为这是棱镜的一部分。毫无疑问,它不是 .NET Framework 的一部分
-
soo ...解决方案是什么?
-
自己实现类或使用像 PRISM 这样的框架。如果您使用 Google,您将找到该课程的来源。
-
没有找到你错的问题 EventToCommand 是 Catel 的一部分,我只是声明它错了"catel.codeplex.com"
-
啊好吧 :) 一切都还好。 @斯蒂安。我不知道这个类存在于哪个框架中:P