I have a WPF GUI that allows the user to open up an options menu. The option menu opens in a new window and is filled with check boxes. When the user presses the "ok" button the window closes. However, it doesn't remember what check boxes were checked when it is opened back up. How do I make sure the program is able to remember what boxes were checked and which ones weren't?
Just to specify: I only need to remember which boxes are checked during the run of the program. The program does not need to remember after the entire program has been exited.
Thanks!
Here is my code under the main window Window1.XAML.CS:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace CartToolsPrototype1
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
// InitializeComponent();
}
//Exit
private void Exit_Click(object sender, RoutedEventArgs e)
{
System.Environment.Exit(0);
}
//Options Window - SAVE CHECKED BOXES
void OpenSettingsWindow()
{
var dlg = new Options();
dlg.DataContext = mGlobalSettings;
dlg.ShowDialog();
}
MySettings mGlobalSettings = new Options();
/* LANGUAGES **/
//English Change
private void English_Click(object sender, RoutedEventArgs e)
{
ResourceDictionary dict = new ResourceDictionary();
dict.Source = new Uri("Lang.en-US.xaml", UriKind.Relative);
this.Resources.MergedDictionaries.Add(dict);
}
//German Change
private void German_Click(object sender, RoutedEventArgs e)
{
ResourceDictionary dict = new ResourceDictionary();
dict.Source = new Uri("Lang.de-DE.xaml", UriKind.Relative);
this.Resources.MergedDictionaries.Add(dict);
}
/* MAIN MENU **/
//Options
private void Options_Click(object sender, RoutedEventArgs e)
{
var newWindow = new Options();
newWindow.Show();
}
}
}
Here is my code under the child Window Options.XAML.CS:
I must still be doing something wrong because the compiler says that I need a get or set "accessor".
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace CartToolsPrototype1
{
/// <summary>
/// Interaction logic for Options.xaml
/// </summary>
public partial class Options : Window
{
public Options()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}
class MySetting : INotifyPropertyChanged
{
public bool IsSettingSet { get; set; }
}