我在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.
更多推荐
" App.Current.myProperty"不工作,但"((应用程序)Application.Current).myProp
发布评论