1、右键项目属性设置增加参数
2、记录控件信息
一般是在某个“确定”按钮中记录下来
public partial class Window2 : Window
{
private void Start_Click(object sender, RoutedEventArgs e)
{
//记录文本框OutFileDirectory中的内容
Properties.Settings.Default.OutFolder = OutFileDirectory.Text;
//记录复选框的选项
Properties.Settings.Default.w2check1 = (bool)this.m1Button.IsChecked;
Properties.Settings.Default.w2check2 = (bool)this.m2Button.IsChecked;
Properties.Settings.Default.Save(); // 保存设置
}
}
3、获取记录的控件信息
一般是在初始化窗体中获取
public partial class Window2 : Window
{
public Window2()
{
WindowStartupLocation = WindowStartupLocation.CenterScreen;
InitializeComponent();
//获取记录的复选框的选择状态
m1Button.IsChecked = Properties.Settings.Default.w2check1;
m2Button.IsChecked = Properties.Settings.Default.w2check2;
//获取记录的文本框的内容
OutFileDirectory.Text = Properties.Settings.Default.OutFolder.ToString();
}
}