D
D
DarkByte20152016-05-07 18:57:03
WPF
DarkByte2015, 2016-05-07 18:57:03

How to catch the moment of selecting a tab?

I need to somehow catch the moment when the TabControl's tab becomes active. (TabItem.IsSelected) And the usual bind will not be enough here. I need exactly the moment when the user opened the tab. I am writing a chat and it will be as if there were messages not read, but read. So what's the best way to catch it? The only thing that comes to mind is to bind the ViewModel to IsSelected and make an infinite loop in a parallel thread that will check this property and perform the necessary actions when it changes. (well, or just call the handler function) Will this option go or are there any better thoughts?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Kovalev, 2016-05-08
@Serguei_Kovalev

For "your" tab, rewrite: protected override void OnVisibleChanged(EventArgs e), and mark if visible: if (this.Visble)... - or do the same for the VisibleChanged event, if you have not created your own class for the tab.

#
#algooptimize #bottize, 2016-05-09
@user004

TabControl has a SelectionChanged event.
If this is not enough, and you need to check for focus changes, then you also need to catch the focus.
Sergey Ronin wrote everything above.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question