简体   繁体   中英

WPF custom control lost its event subscriptions

I've created a complex custom control which contains some basic WPF control and an another custom control. In its OnApplyTemplate, I subscribe to several events. It works as I expected. But if I place this custom control into a TabControl with two tabs (the custom control is in the first tab and I switched to the second one then back to the first tab), the event subscriptions are lost. The debugger doesn't break on the event listeners. Why these event subscriptions are lost after switching tabs in tabcontrol? Thanks for the help in advance.

The loaded event of your custom control fires every time you click on that tab. I think there could be the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM