Note that there are some explanatory texts on larger screens.

plurals
  1. POAll ComboBoxes in a ListBox change when any 1 of them is changed
    primarykey
    data
    text
    <p>I have a <code>ListBox</code> on a form that is bound to an <code>ObservableCollection</code> of a custom type. Within each item there is a <code>ComboBox</code> bound to an enumeration type. When the window loads, all <code>ComboBox</code>es are defaulted to a certain value. When I change the <code>SelectedItem</code> for any one (from the UI, not from code), all other <code>ComboBox</code>es change to the same <code>SelectedItem</code>.</p> <p>I'm not sure what I've done wrong, here is my current XAML that is handling this.</p> <pre><code>&lt;Window.Resources&gt; &lt;ObjectDataProvider x:Key="SyncOperationValues" MethodName="GetNames" ObjectType="{x:Type sys:Enum}"&gt; &lt;ObjectDataProvider.MethodParameters&gt; &lt;x:Type TypeName="local:SyncOperationEnum" /&gt; &lt;/ObjectDataProvider.MethodParameters&gt; &lt;/ObjectDataProvider&gt; ... &lt;DataTemplate x:Key="SyncListTemplate"&gt; &lt;Grid Grid.Column="1" Grid.RowSpan="2" Margin="0,0,20,0" x:Name="olDetails" DataContext="{Binding Path=OlContact}"&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition /&gt; &lt;RowDefinition /&gt; &lt;RowDefinition /&gt; &lt;RowDefinition /&gt; &lt;RowDefinition /&gt; &lt;RowDefinition /&gt; &lt;RowDefinition /&gt; &lt;/Grid.RowDefinitions&gt; ... &lt;ComboBox x:Name="SyncOp" Width="120" Height="19" Margin="4,0,10,0" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Source={StaticResource SyncOperationValues}}" SelectedItem="{Binding Operation}" VerticalAlignment="Center" /&gt; ... </code></pre> <p>and the <code>ListBox</code>:</p> <pre><code> &lt;ListBox x:Name="SyncList" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ItemContainerStyle="{StaticResource StretchedContainerStyle}" ItemTemplate="{StaticResource SyncListTemplate}"&gt; ListBox&gt; </code></pre> <p>I have tried some different options, like binding to a <code>CollectionView</code>; however nothing seems to work. Can anyone point me to my mistake?</p> <p>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.
 

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