我在App对象我自己的公共财产。不过,这并不在我尝试通过 App.Current.myProperty
来访问它的工作。它只能通过工作((APP)Application.Current).myProperty
。
我看到很多样,人们使用 App.Current
来访问自己的属性。难道我错过了什么?覆盖当前
属性?
I have my own public property in App object. But it doesn't work while I trying to access it via App.Current.myProperty
. it work only via ((app)Application.Current).myProperty
.
I see a lot samples where people use App.Current
to access own properties. Did I missed something? Override Current
property?
是的,你应该添加自己的当前
属性到应用
类。
Yes, you should add your own Current
property into your App
class.
这是因为它在默认情况下 Application.Current
返回应用程序
类的实例,而不是你的派生类。
That's because it by default Application.Current
returns Application
class instance, not your derived class.