ViewModel Inheritance

Feb 20, 2012 at 6:24 PM
Edited Feb 20, 2012 at 6:27 PM

Dear all,

I need a "BaseViewModel" which contains some properties needed in all ViewModels on my application.
The ViewModel should for example have properties for Localization using Resource Files.
How can I acive that with Simple MVVM Toolkit?

    public abstract class LocalizableViewModel : ViewModelBase
    {
        private static MUI resources = new MUI();

        public LocalizableViewModel() : base() { }

        protected void SetCulture(string userCulture)
        {
            if (Thread.CurrentThread.CurrentUICulture.Name != userCulture)
            {
                Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(userCulture);
                this.OnPropertyChanged("LocalizedText");
            }
        }

        public MUI LocalizedText
        {
            get
            {
                return resources;
            }
        }

        private string selectedCulture;
        public string SelectedCulture
        {
            get
            {
                return this.selectedCulture;
            }

            set
            {
                if (value != this.selectedCulture)
                {
                    this.selectedCulture = value;
                    this.SetCulture(value);
                    this.OnPropertyChanged("SelectedCulture");
                }
            }
        }
    }

Many thanks for your help,
Ewald