Oliver Apel
Oliver Apel

Reputation: 1878

Binding different Models to different PivotItems

Is it possible to bind different models to different PivotItems in a Pivot-Control?

My PivotItems are

And on both pages I Need different data to Show with different DataTemplates. If yes, can someone show a simple sample?

Upvotes: 1

Views: 133

Answers (1)

Malutek
Malutek

Reputation: 482

If you want your PivotItems to be managed from the different ViewModels, all you have to do is assign each PivotItem with dedicated ViewModel, e.g.:

<Pivot x:Name="PivotContro>
  <PivotItem x:Name="Page1" DataContext="{Binding FirstViewModel, Source={StaticResource ViewModelProvider}}" />
  <PivotItem x:Name="Page2" DataContext="{Binding SecondViewModel, Source={StaticResource ViewModelProvider}}" />
</Pivot>

Upvotes: 1

Related Questions