WPF EventTriggers - 无法转换字符串“MouseEnter” 在属性“RoatedEvent”中; 到“System.Windows.RoatedEvent”类型的对象
我无法让任何事件触发器工作。 我正在做的事情的一个简化示例如下 -
<Window x:Name="win" x:Class="EventTriggers.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<ControlTemplate x:Key="buttonT">
<Border Background="#333">
<TextBlock Text="{Binding}" HorizontalAlignment="Stretch" Foreground="White"/>
<Border.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
</EventTrigger>
</Border.Triggers>
</Border>
</ControlTemplate>
<DataTemplate x:Key="lbt">
<Button Template="{StaticResource buttonT}" Click="Button_Click"></Button>
</DataTemplate>
</Window.Resources>
<ListBox ItemsSource="{Binding ElementName=win,Path=col}" ItemTemplate="{StaticResource lbt}">
</ListBox>
我知道 Border 上有一个 MouseEnter
事件,因为它是在 UIElement
中定义的,但我仍然得到
无法转换字符串“MouseEnter” 属性“RoatedEvent”到对象 输入“System.Windows.RoatedEvent”
当我运行应用程序时,立即
。 任何帮助将不胜感激。
I can't get any event triggers to work. A simplified example of what I'm doing is below -
<Window x:Name="win" x:Class="EventTriggers.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Window.Resources>
<ControlTemplate x:Key="buttonT">
<Border Background="#333">
<TextBlock Text="{Binding}" HorizontalAlignment="Stretch" Foreground="White"/>
<Border.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
</EventTrigger>
</Border.Triggers>
</Border>
</ControlTemplate>
<DataTemplate x:Key="lbt">
<Button Template="{StaticResource buttonT}" Click="Button_Click"></Button>
</DataTemplate>
</Window.Resources>
<ListBox ItemsSource="{Binding ElementName=win,Path=col}" ItemTemplate="{StaticResource lbt}">
</ListBox>
I know there is a MouseEnter
event on Border since it is defined in UIElement
but I'm still getting
Cannot convert string 'MouseEnter' in
attribute 'RoutedEvent' to object of
type 'System.Windows.RoutedEvent'
as soon as i run the application.
Any help would be hugely appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还必须提供类型,因此:
You have to supply the Type as well, so:
完全限定事件名称:
Fully-qualify the event name: