ProjetThe/ProjetTheAlone/ViewModel/Base.cs

48 lines
1.6 KiB
C#
Raw Normal View History

2019-01-18 13:08:55 +01:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Windows.Input;
namespace ProjetTheAlone.ViewModel
{
public class BasePropriete : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
2019-01-18 19:04:54 +01:00
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(name));
}
}
2019-01-18 13:08:55 +01:00
protected void NotifyPropertyChanged(String propertyName)
{ PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); }
protected bool AssignerChamp<T>(ref T field, T value, string propertyName)
{
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
PropertyChangedEventHandler handler = PropertyChanged;
field = value;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName.Substring(4)));
//OnPropertyChanged();
return true;
}
}
public class BaseCommande : ICommand
{
private Action _Action;
public BaseCommande(Action Action_)
{ _Action = Action_; }
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter)
{ return true; }
public void Execute(object parameter)
{ if (_Action != null) _Action(); }
}
}