In my WPF application I’m trying to navigate to other ‘pages’ using the ContentControl.
I have this working so far, in my MainViewModel I have initiated the other viewmodels that should be a part of the MainViewModel.
I display my views with a datatemplate like this:
<DataTemplate DataType="{x:Type vm:NewsViewModel}">
<Views:NewsView />
</DataTemplate>
I got a ItemsControl with TextBlocks to display the View(models) PageName property, when I click on this, it does set the ‘CurrentView’ property to the according ViewModel and it gets displayed. So this aint the problem… However, the issue I come across now is how to let the textblock display the CurrentView I have, for example I want it to be another color then the rest of the textblocks so the user can see which view(model) is active.
I tried to do this in the Style for the textblock with a DataTrigger but this only accepts constant values, any ideas?
Why not switch the
ItemsControlto aListBoxsince it has built-in selection features? You can style it so it hides the selection highlight and looks the same as yourItemsControl, and base your trigger off ofListBoxItem.IsSelected.If you don’t want to do that, you can probably use a IMultiValueConverter to pass the current ViewModel and the active ViewModel to a converter, which would return True if the items are the same, or false if not.