I want to add a Property to the Microsoft.Exchange.WebServices.Data.Folder class. The reason for this is, I need a bool Property "Selected" to bind it in WPF to a checkbox.
First I thought I can use C#-Extensions but currently it's not possible to write a property extension.
Then I created my own class "MyFolder" so I can cast from the Folder class to my class.
It doesn't work either.
public class MyFolder : Folder, INotifyPropertyChanged
{
private bool selected;
public bool Selected
{
get { return selected; }
set { selected = value; OnPropertyChanged("Selected"); }
}
public event PropertyChangedEventHandler PropertyChanged;
public MyFolder(ExchangeService service):base(service)
{
}
protected void OnPropertyChanged(string name)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}
Edit:
I know it would be possible to add a property Folder to the class MyFolder. But I thought it must be possible in a elegant way.
public class MyFolder : INotifyPropertyChanged
{
private bool selected;
public bool Selected
{
get { return selected; }
set { selected = value; OnPropertyChanged("Selected"); }
}
public event PropertyChangedEventHandler PropertyChanged;
public Folder FolderObject { get; set; }
public MyFolder(Folder FolderObject)
{
this.FolderObject = FolderObject;
}
protected void OnPropertyChanged(string name)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
}