Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF Multibinding .Net Framework 4.0
    text
    copied!<p>I have the following DataGridTemplate column:</p> <pre><code>&lt;DataGridTemplateColumn x:Name="specialtiesColumn" Header="Specialties" MinWidth="170"&gt; &lt;DataGridTemplateColumn.CellTemplate&gt; &lt;DataTemplate&gt; &lt;ComboBox ItemsSource="{Binding Path=DataContext.Specialties, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType=DataGrid}}"&gt; &lt;ComboBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Height="17" VerticalAlignment="Center" Orientation="Horizontal"&gt; &lt;CheckBox Width="20"&gt; &lt;CheckBox.IsChecked&gt; &lt;MultiBinding Converter="{StaticResource ProviderSpecialtyIsInSpecialtiesConverter}"&gt; &lt;Binding RelativeSource="{RelativeSource FindAncestor, AncestorType=ComboBox}" Path="DataContext.Specialties" /&gt; &lt;Binding Path="Name" /&gt; &lt;/MultiBinding&gt; &lt;/CheckBox.IsChecked&gt; &lt;/CheckBox&gt; &lt;TextBlock Text="{Binding Name}" Width="130" /&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ComboBox.ItemTemplate&gt; &lt;/ComboBox&gt; &lt;/DataTemplate&gt; &lt;/DataGridTemplateColumn.CellTemplate&gt; &lt;/DataGridTemplateColumn&gt; </code></pre> <p>What I am trying to do is have a column of comboboxes inside a datagrid, and each combobox have several checkboxes. Each row of the datagrid represent hospitals. The combobox will show which specialties the hospital has, and the user should also be able to modify these selections.</p> <p>This is the code for the converter:</p> <pre><code>public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { try { HashSet&lt;Specialty&gt; specialties = (HashSet&lt;Specialty&gt;)values[0]; string specialty = (string)values[1]; foreach (Specialty s in specialties) { if (s.Name == specialty) return true; } return false; } catch (Exception) { return false; } } </code></pre> <p>This works on computers with .Net Framework 4.5, but it crashes when trying to load with only .Net Framework 4.0. The project is targeted for .Net Framework 4.0.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload