如何在页面中处理WPF Mainwindow中更改的连接状态? [英] How to handle connection status changed in WPF Mainwindow from page?

查看:116
本文介绍了如何在页面中处理WPF Mainwindow中更改的连接状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的WPF应用程序中,我在主窗口和框架(导航框架)中有一个用户控件,我的第一页是菜单页面,我将从菜单页面导航到其他页面使用导航服务,这是我的问题。我将在主窗口中连接到硬件设备并在主页面中更新用户控件(显示设备的状态是否已连接),我将使用来自H / W设备提供程序dll的事件处理程序,如果连接状态已更改,现在可以说我是否在应用程序的某个页面中并且连接丢失了。如何更新主窗口的控制状态,我无法在所有页面中实现事件处理程序,我也尝试使用MVVM。



谢谢。

Prabhakaran

Hi,
In my WPF application I am having a user control in main window and a Frame(Navigation frame) and my first page is menu page and I will navigate from menu page to other page using navigation service and here comes my question. I will be connecting to a hardware device in main window and updating the usercontrol(which shows the status of the device as connected or not) in main page and I will be using a event handler from H/W device provider dll which triggers if the connection status changed and now lets say if I am in some of the page in app and the connection got lost. How can I update the main window the control status and I can''t implement the eventhandler in all the pages and I also trying with MVVM.

Thanks.
Prabhakaran

推荐答案

您可以声明一个公共静态属性来存储连接状态。您需要处理每种形式的连接更改。一旦发生连接更改,请从该表单更改Main表单(MainWindow.MyConnection)的静态变量。从此属性的set方法(MyConnection)中拍摄通知程序。
You can declare a public static property to store the connection status. You need to handle connection change in every form. Once connection changed occurred, change the static variable of Main form ( MainWindow.MyConnection) from that form. Shoot the notifier from set method of this property ( MyConnection).


这篇关于如何在页面中处理WPF Mainwindow中更改的连接状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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