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 Telerik.Windows.Data;
using Telerik.Windows.Controls;

using System.ComponentModel;
using System.Collections.ObjectModel;

namespace _799035_RadGridView_WPF_AR_147
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public ObservableCollection<OverviewData> ocOverviewData;
        public MainWindow()
        {
            InitializeComponent();
            ocOverviewData = new ObservableCollection<OverviewData>();
            for (int i = 0; i < 10; i++)
            {
                OverviewData myData = new OverviewData("Name" + i, "Address"+i);
                ocOverviewData.Add(myData);
            }
            
            this.clubsGrid.ItemsSource = ocOverviewData;
            
        }

        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            ocOverviewData.RemoveAt(9);
        }

        private void Button2_Click(object sender, RoutedEventArgs e)
        {
            ocOverviewData[9].ReceiverAddress = "New Name";
        }
    }

    public class OverviewData : INotifyPropertyChanged
    {
        public OverviewData(string _ReceiverName, string _ReceiverAddress)
        {
            this._ReceiverName = _ReceiverName;
            this._ReceiverAddress = _ReceiverAddress;
        }
        private string _ReceiverName;
        public string ReceiverName
        {
            get { return _ReceiverName; }
            set
            {
                if (_ReceiverName == value)
                    return; _ReceiverName = value;
                OnPropertyChanged(new PropertyChangedEventArgs("ReceiverName"));
            }
        }        private string _ReceiverAddress;
        public string ReceiverAddress
        {
            get { return _ReceiverAddress; }
            set
            {
                if (_ReceiverAddress == value)
                    return; _ReceiverAddress = value;
                OnPropertyChanged(new PropertyChangedEventArgs("ReceiverAddress"));
            }
        }        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(PropertyChangedEventArgs e)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, e);
        }
    }
}
