Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
C#
private int _CurrentIndex;

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

On View
C#
SelectedIndex="{Binding Path=CurrentIndex, Mode=TwoWay}

Please help
Posted
Updated 16-Dec-14 1:27am
v2
Comments
Jan Bakker 16-Dec-14 9:15am    
Did you alter the ControlTemplate?
Vi(ky 17-Dec-14 1:12am    
No
db7uk 16-Dec-14 11:14am    
Silly question, but how are you changing the value of the property? Also When you select tabs manually does this change the CurrentIndex property?
Vi(ky 17-Dec-14 1:11am    
yes, CurrentIndex property is changing.

1 solution

After lot of search I found the solution

Here[^]

I have to just write more line of code

C#
e.Handled = true;
 
Share this answer
 
Comments
Member 10376329 4-May-20 19:40pm    
Hello, sorry to ask but where exactly did you add e.Handled=true;?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900