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.RoutedEventArgs) Handles 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.RoutedEventArgs) Handles Button1.Click With oQuizard .Id = Guid.Parse("F58D56AB-DF79-45E1-8574-95C5A7376FC1") .QuizName = "***" .QuizFormalName = "Stephen" End With Me.DataContext = oQuizard End Sub End Class
Hello Mike,
Thank you for your post. I have been looking into and the sample you have sent and I modify it, so now it works as you want. Basically the XamComboEditor and XamMultiColumnComboEditor’ SelectedItem should be bound to an item from their ItemsSource. Also XamComboEditor’s SelectedItem Property is readonly and should use OneWay Binding.
Hope this helps you.
Hi Stefan -
Thanks for responding to my post! The code you wrote is good and answers part of my question but I think what I'm ultimately trying to do is a little more complicated.
Let's say that I want to bind a viewmodel object to the datacontext in the code behind and this viewmodel object is of a different type than the object in my XamMultiColumnComboEditor's itemsource. Is there a way to bind the XamMultiColumnComboEditor's selecteditemproperty to a property value in the viewmodel object? (And when the datacontext is set to the viewmodel object the value in that viewmodel property becomes the selected item in the XamMultiColumnComboEditor.) Also, I'm hoping there is a way to do this using only one datacontext...
Thanks,
Mike
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
I'm all set with this. Thanks for your help!
- Mike
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.