Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've got a Combobox bound in the following fashion:
XAML
<combobox itemssource="{Binding BoomSections}" selecteditem="{Binding XPath=SelectedRodConnectionBoomSection, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" displaymemberpath="BoomSectionInstance.Description" issynchronizedwithcurrentitem="False" />


The problem I'm having is when I initially populate the value of SelectedRodConnectionBoomSection, the Combobox does not show the value of BoomSectionInstance.Description. If I put a breakpoint in the property get, the value is correct, but the value shown in the combobox is blank. If I select a value, I see all of the items populated in BoomSections (with BoomSelectionInstance.Description). I can actually select a value and the value populates on the Combobox as expected. So... The problem appears to be in the initialization of the value. Any thoughts?

BoomSections is defined as:
VB
Public Property BoomSections As ObservableCollection(Of BoomSectionViewModel)
   Get
      Return _boomSections
   End Get
   Set(value As ObservableCollection(Of BoomSectionViewModel))
      _boomSections = value
      NotifyPropertyChanged(Function() BoomSections)
   End Set
End Property


SelectedRodConnectionBoomSection is defined as:
VB
Public Property SelectedRodConnectionBoomSection As BoomSectionViewModel
   Get
      Return _selectedRodConnectionBoomSection
   End Get
   Set(value As BoomSectionViewModel)
      _selectedRodConnectionBoomSection = value
      NotifyPropertyChanged(Function() SelectedRodConnectionBoomSection)
   End Set
End Property


The BoomSectionViewModel contains a property called BoomSectionInstance is defined as:
VB
Public Property BoomSectionInstance As BoomSection
   Get
      Return _boomSectionInstance
   End Get
   Set(value As BoomSection)
      _boomSectionInstance = value
      NotifyPropertyChanged(Function() BoomSectionInstance)
   End Set
End Property


The BoomSection represents an entity defined by:
XML
Namespace Entities

   ''' <summary>
   ''' Class containing Entity Definition for a Boom
   ''' </summary>
   ''' <remarks></remarks>
   <Table("BoomSections")>
   Public Class BoomSection
      Inherits ViewModelBase
      Implements IBaseProperties

      Public Sub New()
         Id = Guid.NewGuid()
      End Sub
      <Key>
      Public Property Id As Guid Implements IBaseProperties.Id
      Public Property Description As String Implements IBaseProperties.Description
   End Class
Posted
Comments
Richard Deeming 4-Aug-15 13:34pm    
Why is your SelectedItem binding using XPath rather than Path?
Andrew Perkins 4-Aug-15 15:09pm    
I've tried both. I just forgot to change it back before I posted the question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900