黑马程序员技术交流社区
标题:
WPF如何绑定Settings内容?
[打印本页]
作者:
zhangcheng5468
时间:
2013-8-2 08:42
标题:
WPF如何绑定Settings内容?
本帖最后由 zhangcheng5468 于 2013-8-2 09:41 编辑
如题:WPF如何更新Settings内容?像WinForm中绑定Settings一样!
作者:
zhangcheng5468
时间:
2013-8-2 09:41
1、Xmal中引入命名空间
xmlns:Properties="clr-namespace:CodeGenerator.Properties"
复制代码
2、绑定控件属性
<TextBox Text="{Binding Path=connstr, Mode=TwoWay, Source={x:Static Properties:Settings.Default}}" />
复制代码
3、退出程序更新Settings
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
Settings.Default.Save();
}
复制代码
作者:
赵宗荣
时间:
2013-8-2 09:42
zhangcheng5468 发表于 2013-8-2 09:41
1、Xmal中引入命名空间2、绑定控件属性3、退出程序更新Settings
正解!:handshake
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2