title: Binding to a method with parameter in XAML using polymorphism in ViewModel
body: <p>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.</p>
  
  <p>The difference is that in ResultTypeOneViewModel, tabs 1 &amp; 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.</p>
  
  <p>I wanted to do this via something like </p>
  
  <pre><code>&lt;TabItem Name="1" Visibility={Binding IsTabVisible(0)}&gt;
  &lt;TabItem Name="2" Visibility={Binding IsTabVisible(1)}&gt;
  &lt;TabItem Name="3" Visibility={Binding IsTabVisible(2)}&gt;
  etc...
  </code></pre>
  
  <p>And have an abstract method declaration in ResultsViewModel such as</p>
  
  <pre><code>public abstract Visibility IsTabVisible(int index);
  </code></pre>
  
  <p>And in ResultsOneViewModel have</p>
  
  <pre><code>public override Visibility IsTabVisible(int index)
  {
      if (index == 0 || index == 2) return Visibility.Visible;
      return Visibility.Hidden;
  }
  </code></pre>
  
  <p>And in ResultsTwoViewModel have</p>
  
  <pre><code>public override Visibility IsTabVisible(int index)
  {
      if (index == 0) return Visibility.Hidden;
      return Visibility.Visible;
  }
  </code></pre>
  
  <p>But I cannot figure out how to call a method like this with a parameter through bindings iN WPF XAML.</p>
  
  <p>Can anyone suggest how I can do this or if it's not possible via this method, another way I could solve this problem?</p>