vasa911
vasa911

Reputation: 79

Windows phone user control change pivot selecteditem

I created my own UserControl, I added Button to it. Also I have Pivot where I added this UserControl. How can I change Pivot selecteditem in Button_Click event in my UserControl.

Binding:

        Binding binding = new Binding("SelectedIndex");
        binding.Source = historyControls[i].SelectedIndex;
        Pivot_Second.SetBinding(Pivot.SelectedIndexProperty, binding);

Upvotes: 0

Views: 494

Answers (1)

Sandeep Chauhan
Sandeep Chauhan

Reputation: 1313

void Button_Click()
{
   SelectedIndex = desiredindex;
}

Make a property

private int _SelectedIndex;
public int SelectedIndex
{
  get
  {
    return _SelectedIndex;
  }
  set
  {
    _SelectedIndex = value;
    RaisedPropertyChanged("SelectedIndex");
  }
}

then bind this property with selected index of your pivot.

I hope it will work.

Upvotes: 1

Related Questions