I have a TabControl with six tabs in my ResultView. The ViewModel that sits behind this View can be either a ResultTypeOneViewModel or ResultTypeTwoViewModel, each of which derives from ResultViewModel but you can interchangeably use the result viewer with either result type.
The difference is that in ResultTypeOneViewModel, tabs 1 & 3 need to be visible and the rest hidden. In ResultTypeTwoViewModel, tabs 2, 3, 4, 5, 6 need to be visible and tab 1 hidden.
I wanted to do this via something like
<TabItem Name="1" Visibility={Binding IsTabVisible(0)}>
<TabItem Name="2" Visibility={Binding IsTabVisible(1)}>
<TabItem Name="3" Visibility={Binding IsTabVisible(2)}>
etc...
And have an abstract method declaration in ResultsViewModel such as
public abstract Visibility IsTabVisible(int index);
And in ResultsOneViewModel have
public override Visibility IsTabVisible(int index)
{
if (index == 0 || index == 2) return Visibility.Visible;
return Visibility.Hidden;
}
And in ResultsTwoViewModel have
public override Visibility IsTabVisible(int index)
{
if (index == 0) return Visibility.Hidden;
return Visibility.Visible;
}
But I cannot figure out how to call a method like this with a parameter through bindings iN WPF XAML.
Can anyone suggest how I can do this or if it's not possible via this method, another way I could solve this problem?