WPF触发器改变光标

编程入门 行业动态 更新时间:2024-10-27 12:26:55
本文介绍了WPF触发器改变光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要更改触发器中的TreeViewItem的游标。此代码适用于所有其他属性,但不适用于Cursor:

I need to change the cursor of a TreeViewItem in a trigger. This code works for all other properties but not Cursor:

<Style.Triggers> <MultiTrigger> <MultiTrigger.Conditions> <Condition Property="QuickPhrases:TreeViewChecker.IsMouseDirectlyOverItem" Value="True"> </Condition> <Condition Property="CanSelect" Value="True"></Condition> </MultiTrigger.Conditions> <Setter Property="BorderThickness" Value="0,0,0,1" /> <Setter Property="BorderBrush" Value="Blue" /> <Setter Property="Cursor" Value="Hand"></Setter> <Setter Property="Foreground" Value="Blue"></Setter> </MultiTrigger> </Style.Triggers>

什么给了,还有我如何正确地做?

What gives, and also, how do I do it correctly?

推荐答案

你做的正确,它应该工作。实际上,我无法通过以下步骤重现您的问题:

You are doing it correctly, it should just work. In fact I'm unable to reproduce your issue via the following steps:

  • 通过VS 2008 C#WPF应用程序向导创建了一个新项目。
    • 产生App.xaml和Window1.xaml

    好吧,这只是工作正常,即一旦悬停在一个TreeViewItem光标被触发到任何值我选择的触发器,无论是手

    Well, this is just working fine, i.e. once hovering over a TreeViewItem the cursor gets triggered to whatever value I chose in the trigger, be it 'Hand' or 'Wait' or else.

    一个重要的细节:光标只会在将标题直接悬停在标题上时出现,即不整行与WPF TreeViewItem行行为一致,但请参阅相关示例的此处行突出显示)。特别是当TeeViewItem标题为空时,光标会出现不!您是否为标头提供了任何数据?

    One important detail though: the cursor only appears while hovering directly over the header, i.e. not the entire row (this is consistent with WPF TreeViewItem row behavior though, see here for a related example regarding row highlighting). Especially the cursor does not appear when the TeeViewItem header is empty! Have you supplied any data for the headers yet?

    否则,它们必须在项目/环境中的幕后发生吗?你已经尝试过这样简单的再现案例了吗?

    Otherwise their must be something weird going on behind the scenes in your project/environment? Have you tried a simple repro case like this already?

更多推荐

WPF触发器改变光标

本文发布于:2023-11-06 04:50:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562753.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:触发器   光标   WPF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!