Note that there are some explanatory texts on larger screens.

plurals
  1. POCan one ComboBox selection be bound to two different data?
    primarykey
    data
    text
    <p>I'm not sure if this is possible or not. I have created a ComboBox like this...</p> <pre><code>&lt;ComboBox Name="testType" Margin="0,5,0,0" IsTextSearchEnabled="True" DisplayMemberPath="Description" SelectedValue="{Binding MyClass.Id, Mode=TwoWay}" SelectedValuePath="Id"/&gt; </code></pre> <p>with code behind that loads up the available options...</p> <pre><code> DataTable testCatList = TestTypeBase.GetAll(); testType.ItemsSource = testCatList.DefaultView; </code></pre> <p>so that it properly displays all the items in MyClass. When the user makes a selection, the Id field in MyClass gets updated as intended. Great.</p> <p>Here's my problem: My testCatList contains both the Id and the Description for each of the rows, and I'd like both of those fields to be bound to the current MyClass instance. So here's what I tried:</p> <pre><code>&lt;ComboBox Name="testType" Margin="0,5,0,0" IsTextSearchEnabled="True" DisplayMemberPath="Description"&gt; &lt;ComboBox.SelectedValue&gt; &lt;MultiBinding Converter="{???}"&gt; &lt;Binding Path="MyClass.Id" Mode="TwoWay"/&gt; &lt;Binding Path="MyClass.Description" Mode="TwoWay"/&gt; &lt;/MultiBinding&gt; &lt;/ComboBox.SelectedValue&gt; &lt;/ComboBox&gt; </code></pre> <p>Here, I'd like to have MyClass.Id set to the selected Id and the MyClass.Description set to the selected Description. As you can see, I have removed the SelectedValuePath because I don't just want the Id any more. But I don't know what to use for the Converter (see the question marks above).</p> <p>Any ideas, oh experts of StackOverflow? Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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