Silverlight的tabchanged事件 - 的tabcontrol [英] Silverlight tabchanged event - tabcontrol

查看:272
本文介绍了Silverlight的tabchanged事件 - 的tabcontrol的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用标签控件,我想处理tabchanged事件。

I'm using tab control and I want to handle tabchanged event.

我试图用的SelectionChanged 事件没有运气。它被解雇次数太多(装载的TabControl,或添加新标签后)。
我想处理此事件,只有当用户选项卡之间进行导航。

I was trying to use SelectionChanged event with no luck. It's being fired too many times (after loading tabcontrol, or adding new tab). I would like to handle this event only when user navigates between tabs.

我已经找到解决方案,WPF(的是否有选定的选项卡更改事件标准WPF Tab控件),但它没有良好的Silverlight的。
TIA。

I have found solution for WPF (Is there Selected Tab Changed Event in the standard WPF Tab Control) but it's no good for Silverlight. TIA.

推荐答案

射击太多次:如果你检查的实际变化不应该是一个问题在的SelectedIndex 属性在事件。

Firing "too many times" should not be a problem if you check for an actual change to the SelectedIndex property in the event.

private int LastSelectedTab = -1;

void tab_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    TabControl tab = sender as TabControl;
    if (this.LastSelectedTab != tab.SelectedIndex)
    {
        this.LastSelectedTab = tab.SelectedIndex;
        // Now do your thing...
    }
}

这篇关于Silverlight的tabchanged事件 - 的tabcontrol的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆