zoukankan      html  css  js  c++  java
  • WPF更新数据源

    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;
    }
    }
    }
    }

  • 相关阅读:
    OpenGL实现通用GPU计算概述
    Android Camera API/Camera2 API 相机预览及滤镜、贴纸等处理
    OpenGL中的Shader
    Android平台Camera实时滤镜实现方法探讨(三)--通过Shader实现YUV转换RBG
    GPU:并行计算利器
    双摄像头测距的OpenCV实现
    Android Camera 通过V4L2与kernel driver的完整交互过程
    图像缩放算法
    双camera景深计算 (1)
    error: ‘shared_ptr’ in namespace ‘std’ does not name a type
  • 原文地址:https://www.cnblogs.com/binbinxiong/p/3721245.html
Copyright © 2011-2022 走看看