Where to store application global variable?
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#.
- Add a property to your data model, or to a Singleton pattern as suggested by Reed.
- 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..."
精彩评论