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;

using System.ComponentModel;

namespace Leo.WpfTest
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.InitData();
}

internal void InitData()
{
IList<ModCls> modsCls = new List<ModCls>();
for (int i = 0; i < 60; i++)
{
ModCls mod = new ModCls();
mod.A = "A" + i;
mod.B = "B" + i;
mod.C = "C" + i;

modsCls.Add(mod);
}

this.gridCls.ItemsSource = modsCls;
this.gridCls.RefreshData();

}

private void Button_Click_1(object sender, RoutedEventArgs e)
{
ModCls mod = new ModCls();
mod.A = "A0";
mod.B = "BB";
mod.C = "CC";

IList<Leo.WpfTest.ModCls> temp = this.gridCls.ItemsSource as List<Leo.WpfTest.ModCls>;
IList<Leo.WpfTest.ModCls> tempA = (from p in temp
where p.A == mod.A
select p).ToList();
if (tempA != null && tempA.Count > 0)
{

for (int i = 0; i < temp.Count; i++)
{
if (temp[i].A == mod.A)
{
temp[i] = mod;
continue;
}
}

this.gridCls.RefreshData();
}
}
}

public class ModCls : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;

private string a;
public string A
{
set
{
a = value;
if (PropertyChanged != null)//有改变
{
PropertyChanged(this, new PropertyChangedEventArgs("A"));
}
}
get
{
return a;
}
}
private string b;
public string B
{
set
{
b = value;
if (PropertyChanged != null)//有改变
{
PropertyChanged(this, new PropertyChangedEventArgs("B"));
}
}
get
{
return b;
}
}
private string c;
public string C
{
set
{
c = value;
if (PropertyChanged != null)//有改变
{
PropertyChanged(this, new PropertyChangedEventArgs("C"));
}
}
get
{
return c;
}
}
}
}

WPF更新数据源的更多相关文章

  1. WPF 自带Datagrid编辑后无法更新数据源的问题

    原文  WPF 自带Datagrid编辑后无法更新数据源的问题 解决办法: 在列的绑定属性里加上UpdateSourceTrigger,示例XAML如下 <DataGrid Grid.Row=& ...

  2. WPF 针对数据源某个属性进行排序

    原文:WPF 针对数据源某个属性进行排序 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/wanlong360599336/article/detai ...

  3. 【C#】让DataGridView输入中实时更新数据源中的计算列

    本文适用Winform开发,且DataGridView的数据源为DataTable/DataView的情况. 理解前提:熟知DataTable.DataView 求:更好方案 考虑这样一个场景: 某D ...

  4. WPF 将数据源绑定到TreeView控件出现界面卡死的情况

    首先来谈一下实现将自定义的类TreeMode绑定到TreeView控件上的一个基本的思路,由于每一个节点都要包含很多自定义的一些属性信息,因此我们需要将该类TreeMode进行封装,TreeView的 ...

  5. WPF 的 数据源属性 和 数据源

    (一)数据源(数据对象)属性 :path 或  path的值(path=VM.Property或M.Property),通常具有通知功能(特例除外). (二)path不能孤立而存在,它一定具有所归属的 ...

  6. WPF绑定数据源之RelativeSource

    Command="{Binding ConfirmRegisterCommand}" CommandParameter="{Binding RelativeSource= ...

  7. Dev GridControl数据修改后实时更新数据源

      1:  /// <summary> 2:  /// 嵌入的ComboxEdit控件选择值变化事件 3:  /// </summary> 4: /// <param n ...

  8. WPF绑定数据源

    using System;using System.Collections.Generic;using System.Collections.ObjectModel;using System.Comp ...

  9. Dev GridControl数据修改后实时更新数据源(转)

    1:  /// <summary> 2:  /// 嵌入的ComboxEdit控件选择值变化事件 3:  /// </summary> 4: /// <param nam ...

随机推荐

  1. 被Play framework狠狠的play了一把

    1.起因 早就听说play framework很火,而且是拯救Java程序员的神器,所以在全国纪念抗战胜利之际,本着学(man)习(zu)研(hao)究(qi)的态度想进行一番尝试. 2. 经过 2. ...

  2. scala中的=>符号的含义

    [声明]本帖的内容是copy来的,来源为stack overflow. It has several meanings in Scala, all related to its mathematica ...

  3. LintCode "Sliding Window Median" & "Data Stream Median"

    Besides heap, multiset<int> can also be used: class Solution { void removeOnly1(multiset<in ...

  4. 百度地图和js操作iframe

    document.getElementById("ifarme-63").contentWindow.document.getElementById("qksv" ...

  5. 使用MyEclipse可视化开发Hibernate实例

    2.7  使用MyEclipse可视化开发Hibernate实例 2.7节的例子源代码在配套光盘sourcecode/workspace目录的chapter02_first项目中. 这个实例主要演示如 ...

  6. asp.net和脚本获取当前的URL、IP地址

    介绍一下ASP.NET取得当前页面的完整URL 的方放,icech做成了函数,直接用吧! private string GetPath() { string strPath = "http: ...

  7. grep 与正则表达式

    正则表达式只是字符串的一种描述,只有和支持正则表达式的工具相结合才能进行字符串处理.本文以grep为例来讲解正则表达式. grep命令 功能:输入文件的每一行中查找字符串. 基本用法: grep [- ...

  8. c++中ifstream读文件的问题(关于eof())

    今天帮别人找BUG,是一段关于c++读写文件的问题,使用的是ifstream与outstream类,关于ofstream与ifstream的用法,此处不再獒述,见代码: #include<ios ...

  9. python 虎扑注册检查脚本

    ulipad,看着蛮舒服的. 图里的代码就是今天晚上的成果. 突然就想看看python这个被很多人说是优雅的语言,于是晚上没事就配了配环境,做了个东西 #encoding: utf-8 import ...

  10. PLSQL_性能优化系列15_Oracle Explain Plan解析计划解读

    2014-12-19 Created By BaoXinjian