Ik heb onderstaande code geminimaliseerd.
Ik vraag me af waarom het ClickEvent niet afvuurt als je een breakpoint hebt geplaatst.
VS2010 Professional SP1 Win7 x64
Ondervinden jullie dit gedrag ook? En heeft iemand hiervoor een verklaring.
Is dit een bug in .NET?
Gecompileerd met .NET 4.0
Ik vraag me af waarom het ClickEvent niet afvuurt als je een breakpoint hebt geplaatst.
VS2010 Professional SP1 Win7 x64
Ondervinden jullie dit gedrag ook? En heeft iemand hiervoor een verklaring.
Is dit een bug in .NET?
Gecompileerd met .NET 4.0
C#:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
| using System; using System.ComponentModel; using System.Windows.Forms; namespace DebuggingClickEvent { public partial class Form1 : Form { //Drag on a form: //Textbox with the name: textBox1 //Button with the Click event directed to button1_Click //Run: //Run the application //Click on the button //Messagebox appears //Set a breakpoint on the line ' _text = value;' //Change the text in the textbox //Click on the button //The messagebox does not appear public Form1() { InitializeComponent(); TextClass t = new TextClass(); textBox1.DataBindings.Add("Text", t, "Text"); t.Text = "This is a default text"; } private void button1_Click(object sender, EventArgs e) { Console.WriteLine("I AM CLICKED"); MessageBox.Show("Clicked"); } } class TextClass : NotifyPropertyChanged { private string _text = string.Empty; public string Text { get { return _text; } set { if (!_text.Equals(value)) { //Put a breakpoint here _text = value; RaisePropertyChanged("Text"); } } } } class NotifyPropertyChanged : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged = delegate { }; public void RaisePropertyChanged(string propertyname) { PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyname)); } } } |
To say of what is that it is not, or of what is not that it is, is false, while to say of what is that it is, and of what is not that it is not, is true. | Aristoteles