如何在Wpf TabControl中更改Tab项? [英] How to change Tab Item in Wpf TabControl?

查看:296
本文介绍了如何在Wpf TabControl中更改Tab项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在研究WPF MVVM项目。在视图上有Tab Control,它有4个Tab项。我想导航到按钮单击时的第一个选项卡项。我实现了一个SelectedIndex属性,如图所示



这里 [ ^ ]



我成功实施了它,但Tab Item在视图中没有变化。我还调试了CurrentIndex的值,更改了值。



在ViewModel中

  private   int  _CurrentIndex; 

public int CurrentIndex
{
get { return _CurrentIndex; }
set
{
_CurrentIndex = value ;
if (PropertyChanged!= null
{
PropertyChanged( new PropertyChangedEventArgs( CURRENTINDEX));
}
}
}



查看

 SelectedIndex =   {Binding Path = CurrentIndex,Mode = TwoWay}  



请帮助

解决方案

经过大量搜索后我找到了解决方案



这里 [ ^ ]



我必须要写更多代码



 e.Handled =  true ; 


Hi
I am working on WPF MVVM project. On view there is Tab Control and it has 4 Tab Items. I want to navigate to the first Tab Item on button click. I implement a "SelectedIndex" property as shown

here[^]

I successfully implemented it but Tab Item not changing in view. I also debug the value of "CurrentIndex", the value changed.

In ViewModel

private int _CurrentIndex;

public int CurrentIndex
{
    get { return _CurrentIndex; }
    set
    {
        _CurrentIndex = value;
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs("CurrentIndex"));
        }
    }
}


On View

SelectedIndex="{Binding Path=CurrentIndex, Mode=TwoWay}


Please help

解决方案

After lot of search I found the solution

Here[^]

I have to just write more line of code

e.Handled = true;


这篇关于如何在Wpf TabControl中更改Tab项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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