开发者

Where to store application global variable?

开发者 https://www.devze.com 2022-12-24 00:09 出处:网络
I\'m using silverlight, project structure is similiar to any other .net app. I have a map control that I would like to store what mode it is in (either road or aerial) so that other controls can acces

I'm using silverlight, project structure is similiar to any other .net app. I have a map control that I would like to store what mode it is in (either road or aerial) so that other controls can access this.

Where do I put this enum variable, I plan to u开发者_如何学Pythonse 2 way binding on it so both are updated when either changes.

Thanks.


You probably will need to implement this as a property within a Singleton, if you want to use data binding in a clean manner.

Jon Skeet has a great post showing how to implement singletons in C#.


  1. Add a property to your data model, or to a Singleton pattern as suggested by Reed.
  2. Follow the INotifyPropertyChanged pattern so that data binding will work.


I found this link about global.asax and the application object helpful: http://odetocode.com/articles/89.aspx

"Which is better: storing object references in the Application object, or making static member variables and properties in the Global class..."

0

精彩评论

暂无评论...
验证码 换一张
取 消