Silverlight tabchanged 事件 - tabcontrol

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

问题描述

我正在使用选项卡控件,我想处理 tabchanged 事件.

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

我试图使用 SelectionChanged 事件,但没有成功.它被触发了太多次(在加载选项卡控件或添加新选项卡之后).我只想在用户在选项卡之间导航时处理此事件.

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 选项卡控件中是否存在 Selected Tab Changed 事件),但这对 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Custom Error Queue Name when using EasyNetQ for RabbitMQ?(使用 EasyNetQ for RabbitMQ 时自定义错误队列名称?)
How to generate password_hash for RabbitMQ Management HTTP API(如何为 RabbitMQ 管理 HTTP API 生成密码哈希)
Rabbitmq Ack or Nack, leaving messages on the queue(Rabbitmq Ack 或 Nack,将消息留在队列中)
Setup RabbitMQ consumer in ASP.NET Core application(在 ASP.NET Core 应用程序中设置 RabbitMQ 消费者)
Specify Publish timeouts in mass transit(指定公共交通中的发布超时)
RabbitMQ asynchronous support(RabbitMQ 异步支持)