如何以WPF形式访问静态全局变量 [英] How to access static global variables in WPF form

查看:377
本文介绍了如何以WPF形式访问静态全局变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以将全局变量保存在app.xaml.cs文件中.

can i keep my global variables in app.xaml.cs file.

如果是,那我将如何访问MyFirstApp.xaml.cs文件中的那些变量?

if yes then how will i access those variables in MyFirstApp.xaml.cs file??

如果否,那么还有什么其他方法可以创建全局变量,以便可以在整个项目中对其进行访问?

if no then what is other alternate to create global variables so that it can be access through out the project??

感谢很多

Mohan

推荐答案

我想我找到了解决方案,就是这样.

i think i got the solution, here it is.

在App.xaml.cs文件中创建一个公共属性,然后在从表单访问它时编写App.<您的属性名称>

create a public property in App.xaml.cs file and while Accessing it from your form write App.<your property name>

非常感谢

Mohan


这篇关于如何以WPF形式访问静态全局变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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