在wpf中哪里是bindingsource [英] where is bindingsource in wpf

查看:369
本文介绍了在wpf中哪里是bindingsource的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Team,



我从Windows表单应用程序迁移到Windows Presentation Foundation(WPF)

但我面临一些问题 -

请帮助 -

1. WPF中的BindingSource在WinForm应用程序中的位置

2.是否有替代代码解决我的问题(

Hello Team,

I am migrating from Windows Form Application to Windows Presentation Foundation(WPF)
But I am facing few issues -
Please Help -
1. Where is "BindingSource" in WPF as we have in WinForm App
2. Is There any alternative code to solve my problem (

Populate & Add/Edit/Delete Records from WPF DataGrid 





例如

我在WinApp Code下面填充和添加/编辑/删除DataGridView中的记录。

我想在WPF中做同样的事情 - Pleseeeee帮助 -





e.g.
I have below WinApp Code to Populate & Add/Edit/Delete Records from DataGridView.
I want to do the same in WPF - Pleseeeee help -

OleDbConnection Con_Admin = new OleDbConnection();
BindingSource bs = new BindingSource();
OleDbDataAdapter da;
DataTable dt;
		public void Show_GridView()
        {            
			Con_Admin.Open();         
            dataGridView1.DataSource = null;            
            da = new OleDbDataAdapter(MyQry, Con_Admin);
            OleDbCommandBuilder MyCommandBuilder = null;
            MyCommandBuilder = new OleDbCommandBuilder(da);
            dt = new DataTable();
            da.Fill(dt);
            bs.DataSource = dt;
            dataGridView1.DataSource = bs;            
            Con_Admin.Close();           
        }
             
        public void SaveChanges()
        {
		try
            {   
                da.Update(dt);
            }
            catch (Exception exceptionObj)
            {
                MessageBox.Show(exceptionObj.Message.ToString());
            }
            Show_GridView();           
        }

推荐答案

我认为您正在寻找 DataContext



/ Fredrik
I think you're looking for DataContext.

/Fredrik


看看这篇文章: WPF DataGrid实例


这篇关于在wpf中哪里是bindingsource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆