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

查看:566
本文介绍了如何在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天全站免登陆