In my MVVM Application I have an object in my MainViewModel
called Products
;
I Also created a CollectionView
to enable navigating in those Products
. What i need is to show the CollectionView.CurrentPosition
.
MainViewModel.cs
private CollectionView collectionView;
public CollectionView CollectionView
{
get { return this.collectionView; }
set
{
this.collectionView = value;
OnPropertyChanged(() => CollectionView);
}
}
public MainViewModel()
{
Products = fillProducts();
CollectionView = (CollectionView) CollectionViewSource.GetDefaultView(Products.Items);
}
Now for displaying the items in the Products
:
<TabItem x:Name="tabProductsView"
DataContext="{Binding Products.Items}"
Header="View Products">
<textBlock Text="{Binding ProductID}" />
<textBlock Text="{Binding ProductDesc}" />
<textBlock Text="{Binding ProductName}" />
...
<TextBlock name="CurrentItemPosition" Text ="{Binding CollectionView.CurrentPosition}"/>
</tabItem>
Now, binding to the Products.Items
is working probably and i can navigate through my products and view the details . But viewing the CollectionView.CurrentPosition
is not working (not showing anything) cause I already set the DataContext
for the hole TabItem
to Products.Items. Also setting the DataContext
of the CurrentItemPosition TextBlock
is not working.
Any ideas on how I can display the CollectionView.CurrentPosition
under this TabItem
?
In other words, how would I bind to another Object
from the MainViewModel
in the same `TabItem?
Thanks in advance.