Reputation: 574
I want to select tab from tab control after creating it.
XAML:
<TabControl SelectedIndex="{Binding SelectedTabIndex}" Name="Items">
<TabControl.Resources>
</TabControl.Resources>
</TabControl>
MainViewModel:
public int SelectedTabIndex
{
get
{
return Items.Count - 1;
}
set { ; }
}
public void AddTab()
{
var chart = new ChartViewModel(this.eventAggregator, this.windowManager);
NotifyOfPropertyChange(() => SelectedTabIndex);
}
ChartViewModel
is a class inherited from Caliburn.Micro.Screen
, MainViewModel
inherits from Caliburn.Micro.Conductor<Caliburn.Micro.Screen>.Collection.OneActive
The tab is created properly, but it is not selected after that.
Upvotes: 1
Views: 344
Reputation: 673
Change your xaml code to something like this,
<TabControl SelectedIndex="{Binding SelectedTabIndex,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Name="Items">
<TabControl.Resources>
</TabControl.Resources>
</TabControl>
Upvotes: 4