private void DoShowPreferences() { var vm = new PreferencesWindowViewModel(_gameConfiguration); var pw = new PreferencesWindow { DataContext = vm }; vm.ShouldClose += (sender, save) => { if (save) { _configuration.Save(ConfigurationSaveMode.Full); Initialize(); } pw.Close(); }; pw.ShowDialog(); }
public PreferencesWindow(PreferencesWindowViewModel viewModel) { DataContext = viewModel; InitializeComponent(); }
public void setDataContext() { vm = new PreferencesWindowViewModel(); generalTabItemViewModel = this.GeneralTabItem.vm; ImageButtonContext close = new ImageButtonContext(); close.ImageSource = TryFindResource("close") as ImageSource; ImageTextButtonContext ok = new ImageTextButtonContext(); ok.ImageSource = TryFindResource("yes") as ImageSource; ImageTextButtonContext cancel = new ImageTextButtonContext(); cancel.ImageSource = TryFindResource("cancel") as ImageSource; ImageButtonContext save = new ImageButtonContext(); save.ImageSource = TryFindResource("save") as ImageSource; ImageButtonContext del = new ImageButtonContext(); del.ImageSource = TryFindResource("delete") as ImageSource; ImageButtonContext def = new ImageButtonContext(); def.ImageSource = TryFindResource("default") as ImageSource; LabeledComboBoxContext setting = new LabeledComboBoxContext(); setting.LabelWidth = 60; setting.ComboBoxWidth = 120; vm.close = close; vm.ok = ok; vm.cancel = cancel; vm.save = save; vm.del = del; vm.def = def; vm.setting = setting; vm.setting.ComboBoxItems = settings.settingNames; vm.header = new LabeledHeaderContext(); vm.general = new LabeledHeaderContext(); vm.player = new LabeledHeaderContext(); vm.staff = new LabeledHeaderContext(); vm.team = new LabeledHeaderContext(); vm.shortlist = new LabeledHeaderContext(); vm.playercolumnsettings = new LabeledHeaderContext(); vm.staffcolumnsettings = new LabeledHeaderContext(); vm.teamcolumnsettings = new LabeledHeaderContext(); vm.shortlistcolumnsettings = new LabeledHeaderContext(); vm.selectedallcolumns = new LabeledHeaderContext(); vm.clearcolumns = new LabeledHeaderContext(); vm.defcolumns = new LabeledHeaderContext(); vm.buttonWarningTooltip = new LabeledHeaderContext(); vm.buttonSaveTooltip = new LabeledHeaderContext(); vm.buttonDeleteTooltip = new LabeledHeaderContext(); vm.buttonSetDefaultTooltip = new LabeledHeaderContext(); vm.buttonUseChangesTooltip = new LabeledHeaderContext(); vm.buttonCancelChangesTooltip = new LabeledHeaderContext(); setControlValues(); setLocalization(); this.DataContext = vm; }