I am in a situation where i try to create notification when i try to switch from one TabItem to another and i try to do so using LostFocus().
Actually my each TabItem consists of TextBlock and some data written on it. So the switching notification i try to achieve like this:
StackPanel sp = new StackPanel()
{
Orientation = Orientation.Horizontal
};
sp.Children.Add(generateTextBlockContaini());
TabItem tbi = new TabItem();
tbi.Header = sp;
tbi.LostFocus +=(o,e) =>
{
//MesssagePop up
MessageBox.Show("Hurrey tabItem changed");
};
The problem arises are:
(1) It works fine but i need to click once on the textblock when i switch to another TabItem in order to popup this messagebox (because its focus is not set if i do not click). Is there any way to set focus of textblock in silverlight 5 ?
(2) Even if it is set it will call infinitely because i replaced textblock by textbox and i used Focus() and it was calling infinitely.