コード例 #1
0
        public void Initialize()
        {
            _settingsService.UpdateTheme();

            _viewModel = new SettingsViewModel
                {
                    Accents = Enum.GetValues(typeof(Accent)).Cast<Accent>().ToList(),
                    SelectedAccent = _settingsService.GetAccent(),
                    Themes = Enum.GetValues(typeof(Theme)).Cast<Theme>().ToList(),
                    SelectedTheme = _settingsService.GetTheme(),

                    IsDirty = false,

                    CloseWindowCommand = new DelegateCommand(CloseSettings),
                    SelectionChangedCommand = new DelegateCommand(CheckDirtyState),
                };

            _viewModel.ApplyChangesCommand = new DelegateCommand(ApplySettings, () => _viewModel.IsDirty);
            _viewModel.SaveChangesCommand = new DelegateCommand(SaveSettings, () => _viewModel.IsDirty);

            _container.RegisterInstance(_viewModel);

            var region = _regionManager.Regions[RegionNames.Settings];
            var view = _container.Resolve<SettingsView>();

            region.Add(view);
        }
コード例 #2
0
        public SettingsView(SettingsViewModel viewModel)
        {
            InitializeComponent();

            DataContext = viewModel;
        }