如何在 WPF 中的两个页面之间传递值 [英] How to pass values between two pages in WPF

查看:33
本文介绍了如何在 WPF 中的两个页面之间传递值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 WPF 中的页面之间传递值的最佳做法是什么?

what is the best practice to pass values between pages in WPF?

谢谢

推荐答案

您的固定参考点是 Application 对象.您可以在 Properties 集合中存储内容:

Your fixed point of reference is the Application object. You can store stuff in the Properties collection:

 string myText = (string)Application.Current.Properties["test"];

或者您可以将任何类型的数据添加到您的派生 App 类中.

Or you can add any kind of data to your derived App class.

这篇关于如何在 WPF 中的两个页面之间传递值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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