繁体   English   中英

如何访问Silverlight 4中App.xaml.cs中创建的自定义属性

[英]How to access custom property created in App.xaml.cs in Silverlight 4

我在app.xaml.cs文件中创建了自己的自定义属性,我需要在我的一个viewmodel中访问此属性。 当我尝试通过Application对象访问时,它不会显示。 谁能帮我这个。

问候

使用Application.Current访问您已创建的自定义属性。

var currentApp =  Application.Current as App;
currentApp.YourPropertyName = "WhateverYouWant";

阅读MSDN上的这篇文章,并举例说明如何操作。

或者只是Application.Current.Properties["YourSavePropertyKey"]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM