How to use MVVM binding to combox?

How to use MVVM binding to combox?

Old forum URL:

simon posted on Thursday, November 18, 2010

I bought the CSLA 4.0 MVVM Serials,  and according to the sample,  i set up a ProductCategoryViewModel, and ProductCategoyrView , in the ProductcategoryView  there a combox for parent product category,  how to bind the ProductCategorListViewModel to the combox itemsource?


Thank you.

griff replied on Friday, November 19, 2010


this is what I've done (binding to namevaluelsit)

<custom:AutoCompleteComboBox x:Name="cboKeywordSearch" Width="200" Margin="10" MaxDropDownHeight="1000" 

SelectedValue="{Binding Path= Model.KeywordID,Mode=TwoWay}

                               SelectedValuePath="Value"  SelectedValue="{Binding Path= KeywordSearch,Mode=TwoWay}" 

                               ItemsSource="{Binding KeywordList, ValidatesOnDataErrors=true, Mode=TwoWay}">





simon replied on Sunday, November 21, 2010

Hi Richard

How to get the keywordList ?  use :CslaDataProvider? 

In my project, I use the code as below, but not work..


 <CollectionViewSource x:Key="productCategorySource" Source="vm:ProductCategoryViewModel" />

   <CollectionViewSource x:Key="productCategoryListSource"Source="vm:ProductCategoryListViewModel"  />



griff replied on Monday, November 22, 2010

This is in my VM:


Private _KeywordList As Abraca.Business.KeywordNVL


        Public Property KeywordList() As Abraca.Business.KeywordNVL


                If _KeywordList Is Nothing Then


                End If

                Return _KeywordList

            End Get

            Set(ByVal value As Abraca.Business.KeywordNVL)

                _KeywordList = value


            End Set

        End Property


        Private Sub LoadKeywordList()

                          Abraca.Business.KeywordNVL.GetBySchoolIDAsync(App.SchoolID, AddressOf LoadKeywordListCompleted)

                    End Sub


        Private Sub LoadKeywordListCompleted(ByVal sender As Object, ByVal e As Csla.DataPortalResult(Of Abraca.Business.KeywordNVL))

            If Not e.Object Is Nothing Then

                KeywordList = e.Object


                MessageBox.Show(e.Error.Message, "Error getting subject index list", MessageBoxButton.OK)

            End If

        End Sub


My combo binds to  KeywordList


Copyright (c) Marimer LLC