How to send property values via eventhandler ?
-
public class Person : INotifyPropertyChanged
{
private string name;public event PropertyChangedEventHandler PropertyChanged; public string Name { get { return name; } set { object before = Name; name = value; OnPropertyChanged("Name", before, Name); } } void OnPropertyChanged(PropertyChangedEventArgs e, object? argvaluebefore = null, object? argnewvalue = null, \[CallerMemberName\] string argcallername = "", \[CallerLineNumber\] int argcallerline = 0) { //How can I inject argvaluebefore and argvalue here ? PropertyChanged?.Invoke(this, e); }
}
public class Master
{Person \_person = new(); public Master() { \_person.PropertyChanged += MyHandler; } private void MyHandler(object? sender, PropertyChangedEventArgs e) { //How do I retrieve the curent values of property Name here plus the value before ? }
}
Hello, I need to retrieve the propery values of class Person in MyHandler of Class Master. Any ideas what I should do ? Regards, Chris
-
public class Person : INotifyPropertyChanged
{
private string name;public event PropertyChangedEventHandler PropertyChanged; public string Name { get { return name; } set { object before = Name; name = value; OnPropertyChanged("Name", before, Name); } } void OnPropertyChanged(PropertyChangedEventArgs e, object? argvaluebefore = null, object? argnewvalue = null, \[CallerMemberName\] string argcallername = "", \[CallerLineNumber\] int argcallerline = 0) { //How can I inject argvaluebefore and argvalue here ? PropertyChanged?.Invoke(this, e); }
}
public class Master
{Person \_person = new(); public Master() { \_person.PropertyChanged += MyHandler; } private void MyHandler(object? sender, PropertyChangedEventArgs e) { //How do I retrieve the curent values of property Name here plus the value before ? }
}
Hello, I need to retrieve the propery values of class Person in MyHandler of Class Master. Any ideas what I should do ? Regards, Chris
You already have this posted in QA: don't post the same question in two places - all you will do is duplicate work and annoy people. Pick either the C# forum or the Q&A and stick with it. Annoyed people are less likely to be helpful than happy ones...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
-
You already have this posted in QA: don't post the same question in two places - all you will do is duplicate work and annoy people. Pick either the C# forum or the Q&A and stick with it. Annoyed people are less likely to be helpful than happy ones...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!
Yea, the following code was one of the examples I tried:
if (e.KeyCode == Keys.F1 && (e.Alt || e.Control || e.Shift))
{
//do sth
}It is from the source you mentioned, but i does not work. Compiler says that
KeyEventArgs
does not contain a definition for Alt etc. Also there is no suggestion of how to fix it. These are my usings: using System; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Reflection; using System.Windows.Forms;
-
Yea, the following code was one of the examples I tried:
if (e.KeyCode == Keys.F1 && (e.Alt || e.Control || e.Shift))
{
//do sth
}It is from the source you mentioned, but i does not work. Compiler says that
KeyEventArgs
does not contain a definition for Alt etc. Also there is no suggestion of how to fix it. These are my usings: using System; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.Reflection; using System.Windows.Forms;
That's because they don't generate keycodes: ALT on it's own does nothing, it needs a keystroke to make it useful - ALT+F2, CTRL+F4 for example. They are MODIFIER keys[^].
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!