Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
260
Data Binding in the Code-Behind
posted

Hi -

I'm trying to bind to a XamComboEditor and a XamMultiColumnComboEditor in the code behind of my vb.net project. If possible, I want to do this binding in a similar fashion to how I bind a WPF combobox. Here is some of the code (I've also attached the entire project):

Imports Infragistics.Controls.Editors
 
Class MainWindow
 
    Dim oQuizard As New ELQuizard
 
    Private Sub Window_Loaded(sender As System.Object, e As System.Windows.RoutedEventArgsHandles MyBase.Loaded
 
        Dim cln As New List(Of ELTester)
        cln.Add(New ELTester() With {.Id = Guid.Parse("F58D56AB-DF79-45E1-8574-95C5A7376FC1"), .Name = "Jon", .FormalName = "Jonathan"})
        cln.Add(New ELTester() With {.Id = Guid.Parse("FE72300E-B8D2-4437-A42E-BA5FCC820DD2"), .Name = "Steve", .FormalName = "Stephen"})
        cln.Add(New ELTester() With {.Id = Guid.Parse("C506CD74-27D6-43D0-9BE9-70959F660151"), .Name = "***", .FormalName = "Richard"})
 
        '---------------
 
        'wpf combobox
        ComboBox1.ItemsSource = cln
        ComboBox1.DisplayMemberPath = "Name"
 
        'ComboBox1.SelectedValuePath = "Id"
        'Dim oBinding As New Binding("Id")
 
        'ComboBox1.SelectedValuePath = "Name"
        'Dim oBinding As New Binding("QuizName")
 
        ComboBox1.SelectedValuePath = "FormalName"
        Dim oComboBox1Binding As New Binding("QuizFormalName")
 
        oComboBox1Binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
        ComboBox1.SetBinding(ComboBox.SelectedValueProperty, oComboBox1Binding)
 
        '---------------
 
        'infragistics comboeditor
        XamComboEditor1.ItemsSource = cln
        XamComboEditor1.DisplayMemberPath = "Name"
 
        XamComboEditor1.ValuePath = "FormalName"
        Dim oXamComboEditor1Binding As New Binding("QuizFormalName")
 
        'oXamComboEditor1Binding.Source = oQuizard
        XamComboEditor1.SetBinding(XamComboEditor.SelectedItemProperty, oXamComboEditor1Binding)
 
        '---------------
 
        'infragistics multicol comboeditor
        XamMultiColumnComboEditor1.AutoGenerateColumns = True
        XamMultiColumnComboEditor1.ItemsSource = cln
 
 
    End Sub
 
    'When the user clicks this button I want all three comboboxes to show their new values
    Private Sub Button1_Click(sender As System.Object, e As System.Windows.RoutedEventArgsHandles Button1.Click
 
        With oQuizard
            .Id = Guid.Parse("F58D56AB-DF79-45E1-8574-95C5A7376FC1")
            .QuizName = "***"
            .QuizFormalName = "Stephen"
        End With
 
        Me.DataContext = oQuizard
 
    End Sub
End Class
ComboBinding.zip