I'm working on c# WinForm.
I have an custom UserControl : MyControl : UserControl, INotifyPropertyChanged
. I attached a method on event on event VisibleChanged : this.VisibleChanged += new System.EventHandler(this.MyControl_VisibleChanged);
My application have some pages, each page is a control like MyControl
. Top of MainWindows contains Button, used to switch tab.
My problem is that my function MyControl_VisibleChanged
is called only when Visible is changing to true. I added a test in a tab to check MyControl.Visible
, when I select the other tab, MyControl.Visible
is false
but no event is raised.
I've try to define a new property Visible for this control but value is never set, only the base
value is modify.
Can you help me to find a solution ?
This is a quirk in the way Visible
works, explained here. His solution was to use properties that he has complete control over, but you could instead have a method allowing the tab switches to tell their children to raise their VisibleChanged
event that extra time.
The first two answers to this question may also be useful.