title: WPF Binding to a function return
body: <p>I have a "Checked ListBox", a <code>ListBox</code> with a <code>CheckBox</code> for each of my Items.<br>
  In this <code>ListBox</code> I have a List of Players.</p>
  
  <pre><code>&lt;ListBox ItemsSource="{Binding MyPlayers}" SelectedItem="{Binding SelectedPlayer}" Margin="69,51,347.4,161.8"&gt;
      &lt;ListBox.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;ListBoxItem&gt;
                  &lt;CheckBox IsChecked="{Binding ???}" Content="{Binding Path=Pseudo}" /&gt;
              &lt;/ListBoxItem&gt;
          &lt;/DataTemplate&gt;
      &lt;/ListBox.ItemTemplate&gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>ViewModel :</p>
  
  <pre><code>public class MainWindowViewModel : BaseViewModel
  {
      SavingContext MyDatabaseContext;
      public ObservableCollection&lt;Player&gt; MyPlayers
      {
          get
          {
              return MyDatabaseContext.MyPlayers.Local;
          }
      }
  
      Tournament _MyTournament;
      public Tournament MyTournament
      {
          get
          {
              return _MyTournament;
          }
  
          set
          {
              _MyTournament = value;
          }
      }
  
      public MainWindowViewModel(Tournament myTournament)
      {
          MyDatabaseContext = new SavingContext();
          MyDatabaseContext.MyPlayers.Load();
          MyTournament = myTournament;
      }
  }
  </code></pre>
  
  <p>I pass in my <code>ViewModel</code> a <code>Tournament</code>, that contains an <code>HashSet</code> of <code>Players</code> called <code>Participants</code>.<br>
  I would like to bind my <code>IsChecked</code> properties to the result of <code>MyTournament.Participants.Contains(this)</code> with this being the <code>Player</code> related to the <code>CheckBox</code>. But I can't manage to make it works.  </p>
  
  <p>Edit :<br>
  I tried to use a Converter, but with no success.
  <code>&lt;helper:PlayerToTournamentRegistered x:Key="PlayerToTournamentRegistered" /&gt;</code></p>
  
  <pre><code>&lt;ListBoxItem&gt;
      &lt;CheckBox IsChecked="{Binding Converter={StaticResource PlayerToTournamentRegistered}}" Content="{Binding Path=Pseudo}" /&gt;
  &lt;/ListBoxItem&gt;
  
  public class PlayerToTournamentRegistered : IValueConverter
  {
      public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          //Temp test to see if it would work
          if (value == null) return false;
  
          return true;
      }
  
      public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          throw new NotImplementedException();
      }
  }
  </code></pre>
  
  <p>I get an error each time <code>Provide value on 'System.Windows.Data.Binding' threw an exception</code><br>
  Any Advices ?</p>