如何从 WPF 中的用户控件引发父事件? [英] How can I raise a parent event from a user control in WPF?

查看:71
本文介绍了如何从 WPF 中的用户控件引发父事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个加载到父窗口中的用户控件,我想在单击用户控件上的按钮时引发父事件.如何通过 WPF 中的用户控件与父级通信?

I have a user control that is loaded into the parent window, and I want to raise a parent event when a button on the user control is clicked. How can I communicate with the parent through my user control in WPF?

推荐答案

首先想到的方法是让您的 UserControl 引发父窗口正在侦听的事件.然后,父母可以引发您想要的事件.

First way that comes to mind is to have your UserControl raise an event that the parent window is listening to. The parent can then raise the event you want.

这篇关于如何从 WPF 中的用户控件引发父事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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