Note that there are some explanatory texts on larger screens.

plurals
  1. POC# WPF How to Pass an object of an observable collection from the property of the object
    text
    copied!<p>thank you for reading my question.</p> <p><strong>Situation:</strong></p> <p>I have an observable collection</p> <pre><code>CheckableTags = new ObservableCollection&lt;CheckableListItem&lt;Item&gt;&gt;(); </code></pre> <p>The wrapper class <code>CheckableListItem&lt;Item&gt;</code> adds a bool per object Item.</p> <pre><code>public class CheckableListItem&lt;T&gt; : 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("ENTIRE OBJECT HERE"); } } 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)); } } </code></pre> <p>When the user checks the checkbox, the bool variable is changed, this is why I fire the function <code>MeasConSettings.Current.CheckableTags_CheckedChanged("ENTIRE OBJECT HERE");</code> in the property of the bool variable.</p> <p>The function is as following:</p> <pre><code>public void CheckableTags_CheckedChanged(object sender) {} </code></pre> <p><strong>My question is:</strong> 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.</p> <p>If possible get a reference to the object so I can copy it in the receiving function.</p> <p><strong>Alternatives:</strong> If this is not possible, what else can I do? </p> <p>Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload