将 isEnabled=true 设置为父控件后,超链接保持非活动状态 [英] Hyperlinks are staying inactive after setting isEnabled=true to parent control

查看:26
本文介绍了将 isEnabled=true 设置为父控件后,超链接保持非活动状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含列表框的 TabItem,它有一个我的提要类的可观察集合作为它的项目源.当我将提要刷新/加载到集合中时,我想禁用主窗口,以便用户在此过程运行时无法单击其他内容.所以我将 tbCtrl.isEnabled=false; 设置为表单上的选项卡控件.然后将事件处理程序分配给在加载所有提要后触发的自定义完成事件.

I've got a TabItem contanining a listbox, which has an obeservable collection of my feeds class as its item source. When I refresh/load the feeds into the collection I want to disable the main window so that the user can't go clicking other things while this process is running. So I set tbCtrl.isEnabled=false; to my tab control on the form. Then assign an event handler to the a custom finish event which is triggered after all the feeds are loaded.

这一切正常,但是当前显示在选项卡控件上的结果的超链接永远不会重新启用(也不会重新启用接下来的几个由于列表框大小而看不见的).进一步向下的所有其他结果都很好,另一个选项卡上的结果也是如此.

This all works fine, however the hyperlinks for the results which are currently displayed on the tab control never get re-enabled (Nor do the next few which are out of view due to the list box size). All the other results further down are fine, as are the results on the other tab.

我尝试在一切完成后在选项卡控件上调用 InvalidateVisual,看看这是否有所不同,但似乎没有引起任何变化.

I've tried calling InvalidateVisual on the tab control after everything is finished, to see if that makes a difference but that doesn't seem to cause any change.

如果所有超链接都在做,或者只是当前显示的超链接,我可以理解,但我不明白为什么滚动之外的超链接也不起作用.

I could understand it if it was all Hyperlinks doing it, or just the ones currently displayed, but I don't understand why ones which are out of scroll are not working either.

推荐答案

我找到了解决我的超链接没有重新启用的情况的答案,不确定它是否适用于您的:

I found the answer for my case of the hyperlink not getting re-enabled, not sure if it applies to yours:

我发现当 Hyperlink 的父控件被禁用 (IsEnabled=false) 时,Hyperlink 将不会收到更改通知,例如即使绑定属性更改了值,也不会触发 IsEnabledChanged.

I found that when the Hyperlink's parent control is disabled (IsEnabled=false), the Hyperlink will not get notified of changes, e.g. IsEnabledChanged does not get fired, even when the bound property changes value.

我的解决方案是更改我的 Xaml 以不再禁用祖先控件(这会导致超链接的父控件被禁用).始终启用父级 (TextBlock),现在超链接始终正确更新.

My solution was to change my Xaml to no longer disable the ancestor control (which was causing the Hyperlink's parent to be disabled). With the parent (TextBlock) always enabled, now Hyperlink updates properly always.

(我有点担心 IsEnabled 绑定的行为与 Controls 不同,我不确定如果我不能让祖先处于启用状态,我会怎么做……但至少这让我明白了我遇到的问题,让我解决它.)

(I'm a little bothered that the IsEnabled binding behaves differently than Controls do, and I'm not sure what I would do if I couldn't leave the ancestor enabled... but at least this lets me understand the issue I was having, and lets me work around it.)

详细信息:WPF 3.5 SP1

这篇关于将 isEnabled=true 设置为父控件后,超链接保持非活动状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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