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

标签 c# wpf silverlight

我在 app.xaml.cs 文件中创建了自己的自定义属性 我需要在我的一个 View 模型中访问此属性。 当我尝试通过应用程序对象访问时,它没有出现。 谁能帮我解决这个问题。

问候

最佳答案

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

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

阅读此 article on MSDN举例说明如何操作。

关于c# - 如何访问在 Silverlight 4 的 App.xaml.cs 中创建的自定义属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8983546/

相关文章:

c# - 是否可以概括元组属性?

c# - 在 WPF 应用程序 C# 中设置所有矩形的背景

silverlight - 多个 ViewModel 之间的数据共享

c# - Windows Phone:无法使ViewportControl对齐

c# - 访问元素组件 silverlight

c# - 适用于 C# 和 Windows 窗体应用程序开发人员的 .Net framework 4.0 有哪些新功能?

c# - C# 中的正则表达式问题

c# - 调用另一个 Controller 的 Action 并将 View 作为字符串

wpf - 如何在没有 AttachedProperty 或 DependencyProperty 的情况下使用 IDataErrorInfo 验证密码框?

.net - 在 WPF 中更改当前文化后,即时强制更新 UI