Monday, 9 September 2013

C# WPF How to Pass an object of an observable collection from the property of the object

C# WPF How to Pass an object of an observable collection from the property
of the object

thank you for reading my question.
Situation:
I have an observable collection
CheckableTags = new ObservableCollection<CheckableListItem<Item>>();
The wrapper class CheckableListItem<Item> adds a bool per object Item.
public class CheckableListItem<T> : INotifyPropertyChanged
{
private bool mIsChecked;
private T mItem;
public event PropertyChangedEventHandler PropertyChanged;
public CheckableListItem(T item)
{
mItem = item;
}
public bool IsChecked
{
get
{
return mIsChecked;
}
set
{
mIsChecked = value;
OnPropertyChanged("IsChecked");
MeasConSettings.Current.CheckableTags_CheckedChanged(this);
}
}
public T Item
{
get
{
return mItem;
}
set
{
mItem = value;
OnPropertyChanged("Item");
}
}
protected virtual void OnPropertyChanged(string propertyName)
{
var handler = PropertyChanged;
if (handler != null)
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
When the user checks the checkbox, the bool variable is changed, this is
why I fire the function
MeasConSettings.Current.CheckableTags_CheckedChanged("ENTIRE OBJECT
HERE"); in the property of the bool variable.
The function is as following:
public void CheckableTags_CheckedChanged(object sender)
{}
My question is: How can I send the entire object from the property of the
bool to the function in my viewmodel, what should I send in the field
"ENTIRE OBJECT HERE" in order to receive an object of CheckableListItem
class with 2 elements the bool variable and the Item.
Alternatives: If this is not possible, what else can I do?
Thanks in advance.

No comments:

Post a Comment