Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Binding DataGrid

Binding DataGrid

Scheduled Pinned Locked Moved WPF
wpfcsharpwcflinq
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sawyer1988
    wrote on last edited by
    #1

    Explain why the method works so crooked add to the collection and display DataGrid.Ispolzuyu binding in XAML

    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    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;

    namespace bild
    {
    public partial class MainWindow : Window
    {

        public MainWindow()
        {
            InitializeComponent();
        }
    
        private void button1\_Click(object sender, RoutedEventArgs e)
        {
            ViewModel r = new ViewModel();
            r.ad();
            dataGrid1.ItemsSource = r.Persons;
        }
    }
    public class ViewModel
    {
        public ViewModel()
        {
            this.Persons = new
    
    A 1 Reply Last reply
    0
    • S Sawyer1988

      Explain why the method works so crooked add to the collection and display DataGrid.Ispolzuyu binding in XAML

      using System;
      using System.Collections.Generic;
      using System.Collections.ObjectModel;
      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;

      namespace bild
      {
      public partial class MainWindow : Window
      {

          public MainWindow()
          {
              InitializeComponent();
          }
      
          private void button1\_Click(object sender, RoutedEventArgs e)
          {
              ViewModel r = new ViewModel();
              r.ad();
              dataGrid1.ItemsSource = r.Persons;
          }
      }
      public class ViewModel
      {
          public ViewModel()
          {
              this.Persons = new
      
      A Offline
      A Offline
      Andy411
      wrote on last edited by
      #2

      What is the exact problem? After a quick view, I see two things: 1) After calling the ctor of ViewModel, there will be Ivan, Stefan, Maria and Michael in the Persons collection. After calling ViewModel.Add() there will be only Maria and Michael, because you create a new collection. 2) class Person needs to implement INotifyPropertyChanged and after changing a property it has to call the PropertyChangedEvent. Hope it helps Andy

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups