Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从chache获取用户设置在WPF MVC中不起作用#_C#_Wpf_Binding - Fatal编程技术网

C# 从chache获取用户设置在WPF MVC中不起作用#

C# 从chache获取用户设置在WPF MVC中不起作用#,c#,wpf,binding,C#,Wpf,Binding,我喜欢将用户输入保存到用户设置中,每次重新启动应用程序后,我喜欢他们从设置中获取“新”字符串 但每次用户设置都是空的。不知道为什么。有人能帮我吗 以下是压缩代码: 查看数据上下文位于代码behinde中: <UserControl.Resources> <m:Model x:Key="model"/> </UserControl.Resources> <TextBox x:Name="txtbx_user" Text="{Binding Use

我喜欢将用户输入保存到用户设置中,每次重新启动应用程序后,我喜欢他们从设置中获取“新”字符串

但每次用户设置都是空的。不知道为什么。有人能帮我吗

以下是压缩代码:

查看数据上下文位于代码behinde中:

<UserControl.Resources>
    <m:Model x:Key="model"/>
</UserControl.Resources>

<TextBox x:Name="txtbx_user" Text="{Binding UserName}"/>
是的,我已经在项目的属性中设置了字符串

为什么每次重新启动应用程序时,Properties.Settings.Default.UserName中都会出现一个空字符串

谢谢你们

正如所指出的,一旦发生更改,就会丢失Save语句

Properties.Settings.Default.UserName = _userName;
Properties.Settings.Default.Save();

检查您要更新的设置是否定义为用户级别。。同时也不要忘记调用Properties.Settings.Default.Save();
Properties.Settings.Default.UserName = _userName;
Properties.Settings.Default.Save();