using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Input;
namespace LVIterate
{
public class ViewModel : INotifyPropertyChanged
{
private CollectionViewSource cvs = new CollectionViewSource();
public ICollectionView View
{
get
{
cvs.Source = InitImput();
return cvs.View;
}
}
public ICommand Cmd { get => new RelayCommand(CmdExec); }
private void CmdExec(object parameter)
{
switch (parameter.ToString())
{
case "Iterate":
//for (int i = 0; i < NameOfListView.Items.Count; i++)
//{
// Output.Add((Model)Items[i]);
//}
MessageBox.Show("Items Added");
break;
default:
break;
}
}
ObservableCollection Output = new ObservableCollection();
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
ObservableCollection Input = new ObservableCollection();
public ObservableCollection InitImput()
{
Input.Add(new Model() { Cont1 = "1", Cont2 = "A", Cont3 = "a"});
Input.Add(new Model() { Cont1 = "2", Cont2 = "B", Cont3 = "b"});
Input.Add(new Model() { Cont1 = "3", Cont2 = "C", Cont3 = "c"});
Input.Add(new Model() { Cont1 = "4", Cont2 = "D", Cont3 = "d"});
return Input;
}
}
public class Model
{
public string Cont1 { get; set; }
public string Cont2 { get; set; }
public string Cont3 { get; set; }
}
public class RelayCommand : ICommand
{
private readonly Predicate