开发者

Trying find how to cancel TabControl.SelectionChanged in Silverlight

I am trying figure out how cancel this event in Silverlight, sadly I didn't find any useful link with the solution. (I saw some post for wpf which开发者_Python百科 I think are not longer available for Silverlight)


Here is the bare bones of it:-

    bool cancellingTabSelectionChange = false;
    private void tabControl1_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        if (e.RemovedItems.Count > 0 && !cancellingTabSelectionChange)
        {
            cancellingTabSelectionChange = true;
            ((TabControl)sender).SelectedItem = e.RemovedItems[0];
            cancellingTabSelectionChange = false;
        }
    }

You would need to add the extra criteria the would allow a change to take place since the above code would always block a change of tab.


As i know there is not straight way to cancel it. You can disable control if dont want change tab, or set selectedtab to which you want after selectionchanged fired.

 private void tabControl1_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        tabControl1.SelectedIndex = [index of tab]
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜