问题标签 [routed-events]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1549 浏览

wpf - 为什么此代码中未引发 FrameworkElement.SizeChanged

根据文档“(FrameworkElement.SizeChanged)在此元素的 ActualHeight 或 ActualWidth 属性更改值时发生。”

运行以下测试方法,我的 Rectangle 的 ActualWidth 和 ActualHeight 在调用 Measure 和 Arrange 后更新,但是 SizeChanged RoutedEvent 永远不会引发。

谁能解释为什么没有提出 SizeChanged ?
有没有办法可以设置它以便提高它?


解决方案

该测试通过了 HB 的静态类:

0 投票
1 回答
546 浏览

c# - WPF 为 Button_Click 建立隧道

这是我的第一个问题,所以请放轻松:)

我是 WPF 和基于桌面的应用程序的新手,我正在学习事件处理。通过冒泡和隧道我在任何地方都找不到解释如何在 Button_Click 上使用隧道的示例。

基本上,当我单击一个按钮时,我需要父控件(在本例中为网格)首先处理事件并在允许 Button_Click 发生之前进行一些检查。我遇到的问题是我可以使用 Grid_PreviewMouseDown 来捕获事件,但这是不明确的!它没有告诉我(至少我认为它没有)是什么控制导致处理程序触发。

我该怎么做才能确定 PreviewMouseDown 是由按钮单击触发的?或者:是否有替代/更好的方法是隧道 Button_Click?

谢谢

0 投票
2 回答
4542 浏览

c# - 在 selectionchanged 事件上禁用事件冒泡 - WPF

我在列表视图中有一个列表框。在他们两个上,我都有 selectionchanged 事件。当我触发子控件事件时,父控件会自动触发。我需要停止这种行为。有什么提示吗?谢谢!

--

0 投票
1 回答
91 浏览

wpf - 有哪些方法可以在不使用代码隐藏的情况下处理双击事件?

我看到一篇文章详细介绍了如何使用我非常喜欢的附加行为来做到这一点。但是,下载不起作用,而且这篇文章已经很老了(几年了)。

当前在不使用代码隐藏的情况下处理此类事件的方法是什么?有没有特定于 MVVM 的?

0 投票
1 回答
483 浏览

c# - Silverlight 3 中的路由事件?

我有一个控件,在一个控件内,在一个控件内。

像这样。。

QuizMaster -> 问题 -> 答案 -> 单选按钮

当检查其中一个答案时,我希望Quizmaster中的函数称为AskNextQuestion()运行。

我怎么做?

0 投票
2 回答
867 浏览

wpf - 用户控件中的 WPF 路由事件处理

我有一个包含按钮的 WPF UserControl。我还有一个包含按钮的 WPF 窗口。在 UserControl 和 Window 中,我将以下行放在 XAML 中:

在“OnPreviewMouseLeftButtonDown”中,我放置了一个显示 args.Source 的调试打印。

当我单击窗口内的按钮时,我将按钮作为 EventArgs 源。但是,当我单击 UserControl 内的按钮(它也在一个窗口内,所以我可以测试它,但不是同一个窗口)时,我将 UserControl 作为 EventArgs 源。

我很想看看 UserControl 周围是否有一些装饰器(使用 snoop),但它看起来很简单。

我无法理解 WPF 中的 UserControl 有什么特别之处,以至于我没有找到正确的发件人。有人可以向我解释我错过了什么吗?

0 投票
2 回答
473 浏览

c# - 为 RoutedEvent 创建自定义事件处理程序

给定一个路由事件标识符。

可以使用反射为该事件创建一个处理程序?(当然在处理程序中添加一些代码)。

0 投票
1 回答
457 浏览

wpf - 从弹出窗口监听路由事件/命令

我有一个动态创建弹出窗口的控件。

弹出窗口包含触发路由事件/命令的控件,我想在原始控件中对其做出反应。原来的控件被设置为弹窗的放置目标。

您希望原始控件接收冒泡事件吗?我知道它在不同的视觉树中,但我想知道它们是否会被提供给放置目标。从我的代码看来不是。

任何人都可以提出一种处理这种情况的方法吗?响应不同视觉树中的事件。我想知道是否有一些我可以编写的控件位于弹出窗口的根目录中并充当原始视觉树的“桥梁”?

非常感谢,

0 投票
1 回答
222 浏览

wcf-ria-services - WCF RIA Services / intercept or subscribe to a RaiseDataMemberChanging

So I'm new to the concept of routed events, but I know that messages are flying everywhere when fields are changing via the RaiseDataMemberChanging / RaiseDataMemberChanged messages.

The quick question is how to I "listen" for those routed messages?

I would like my view model, in a MVVM correct matter, intercept a message that a field is being updated, deep down in the heirarchy of tables. If a change occurs in a child (a date range), that date range change has some business logic associated with it that works from top down.

I've know that I can use partial methods to inject code during the changing and changed events, but the design (one to one relationship) means that a change to the child, in the context of the child, has no reference the parent (Parent has a one to one reference to child, but child has no reference to parent).

Yes I can add the reference from the child to the parent (making the parent have both a one to one, as well as a one to many relationship), but during creation of the entity, this creates a problem - parent has to exist before the child entity exists, and the child entity has to exist before a reference to the parent can exist. This design requires an insert of the parent, and child, then an update of the child - which confuses WCF RIA Services during the inital creation process.

Sorry for the long winded explaination, but I'll even consider design changes if this all makes sense to anyone that cares to comment.

Any input would be appreciated.

0 投票
1 回答
2319 浏览

c# - 路由事件和依赖属性 .NET 包装器混淆

我是 WPF 的新手,对路由事件和依赖项属性的包装语法感到困惑,我在许多源中看到路由事件和依赖项属性是这样包装的

我从未见过 C# 中的 add / remove / set / get 排序关键字。这些是作为关键字的 C# 语言的一部分吗?我从未体验过或使用过它们,因为我没有在 C# 中工作过,因为我是一名 C++ 程序员?如果不是关键字,那么如果它们不是 C# 的一部分,编译器将如何处理它们以及它们是如何工作的