Mutually Exclusive comboboxes that binds to same data source - MVVM implementation
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Mutually Exclusive comboboxes that binds to same data source - MVVM implementation

  1. #1
    Join Date
    Mar 2011
    Posts
    1

    Mutually Exclusive comboboxes that binds to same data source - MVVM implementation

    I'm not sure my Title is right but this is the problem I am facing now.. I have the below XAML code..

    <ItemsControl ItemsSource="{Binding Path=FieldMapping}">
    <ItemsControl.ItemTemplate>
    <DataTemplate>
    <StackPanel Orientation="Horizontal">
    <ComboBox ItemsSource="{Binding Path=AvailableFields}"
    SelectedItem="{Binding Path=SelectedField}"
    ></ComboBox>
    </StackPanel>
    </DataTemplate>
    </ItemsControl.ItemTemplate>
    </ItemsControl>

    What this basically does is, If my data source contains ten items, this is going to generate 10 row of comboboxes and all comboboxes are bounded to the same itemsource.

    Now my requirement is Once an item is selected in the first combo box, that item should not be available in the subsequent combo boxes. How to satisfy this requirement in MVVM and WPF?

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    10,967

    Re: Mutually Exclusive comboboxes that binds to same data source - MVVM implementatio

    You'll need to add the logic to the VM to remove the selected item from the subsequent lists when a user makes a selection. I doubt there is a xaml only solution, so you'll probably need to handle the selectchange event.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center