XAML:为什么这个触发器不起作用?
我想在样式之外使用触发器。 编辑:哎呀,抱歉,它实际上在 MainWindow 的样式内,但我希望触发器应用于 Ellipse 而不是 MainWindow。
<Ellipse Fill="White" StrokeThickness="1" Stroke="Black">
<Ellipse.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Fill" Value="Yellow"/>
</Trigger>
</Ellipse.Triggers>
</Ellipse>
如何修复编译器错误“无法在“MainWindow”类型上找到静态成员“FillProperty””?
I'd like to use a trigger outside a style. Edit: whoops, sorry, it's actually inside a style for MainWindow, but I want the trigger to apply to the Ellipse and not MainWindow.
<Ellipse Fill="White" StrokeThickness="1" Stroke="Black">
<Ellipse.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Fill" Value="Yellow"/>
</Trigger>
</Ellipse.Triggers>
</Ellipse>
How do I fix the compiler error, which is "Cannot find the static member 'FillProperty' on the type 'MainWindow'"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你必须把它放在风格上
you have to put this in style
在直接触发器中,您需要像这样限定类型名称:
但这不起作用,因为直接触发器只允许
EventTriggers
,请改用 Style。In direct Triggers you need qualifying type names like so:
This won't work though since direct triggers only allow
EventTriggers
, use a Style instead.您的窗口没有像椭圆那样具有名为“Fill”的属性。也许你的意思是“背景”。
Your window doesn't have a property named "Fill" like an Ellipse does. Maybe you mean "Background".