This works. However I have a follow up question.
How do I get the selected item of the combobox (in the CollectionControl)?
For example in my case the objects listed in the comboBox are Fabrics
I thought maybe I need to add a SelectedFabric property to the class and then add SelectedValue="{Binding SelectedFabric}" and SelectedValuePath in the ComboBox EditorTemplateDefinition, e.g. in Xceed.Wpf.Toolkit/CollectionControl/Themes/Generic.xaml
How do I get the selected item of the combobox (in the CollectionControl)?
For example in my case the objects listed in the comboBox are Fabrics
I thought maybe I need to add a SelectedFabric property to the class and then add SelectedValue="{Binding SelectedFabric}" and SelectedValuePath in the ComboBox EditorTemplateDefinition, e.g. in Xceed.Wpf.Toolkit/CollectionControl/Themes/Generic.xaml
<pg:PropertyGrid Grid.Row="1"
Grid.Column="1"
Margin="0,5,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
SelectedObject="{Binding SelectedItem, RelativeSource={RelativeSource TemplatedParent}}"
IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}">
<pg:PropertyGrid.EditorDefinitions>
<pg:EditorTemplateDefinition TargetProperties="ListOfFabrics">
<pg:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding Value}" SelectedValue="{Binding SelectedFabric}" SelectedValuePath="FabricID"/>
</DataTemplate>
</pg:EditorTemplateDefinition.EditingTemplate>
</pg:EditorTemplateDefinition>
</pg:PropertyGrid.EditorDefinitions>
</pg:PropertyGrid>
where I havePublic Class FabricLayer
Implements INotifyPropertyChanged
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Sub OnPropertyChanged(ByVal e As PropertyChangedEventArgs)
If Not PropertyChangedEvent Is Nothing Then
RaiseEvent PropertyChanged(Me, e)
End If
End Sub
Public myThickness As Double
Public myListOfFabrics As New List(Of Fabric)
Public mySelectedFabric As Integer
Public Property Thickness() As Double
Get
Return myThickness
End Get
Set(ByVal value As Double)
myThickness = value
OnPropertyChanged(New PropertyChangedEventArgs("Thickness"))
End Set
End Property
Public Property ListOfFabrics As List(Of Fabric)
Get
Return myListOfFabrics
End Get
Set(ByVal value As List(Of Fabric))
myListOfFabrics = value
End Set
End Property
Public Property SelectedFabric As Integer
Get
Return mySelectedFabric
End Get
Set(ByVal value As Integer)
mySelectedFabric = value
OnPropertyChanged(New PropertyChangedEventArgs("SelectedFabric"))
End Set
End Property
and Public Class Fabric
Implements INotifyPropertyChanged
Public myGUID As String
Public myDisplayColour As System.Windows.Media.Color
Public myDescription As String
Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
Public Sub OnPropertyChanged(ByVal e As PropertyChangedEventArgs)
If Not PropertyChangedEvent Is Nothing Then
RaiseEvent PropertyChanged(Me, e)
End If
End Sub
Public Sub New()
myGUID = Guid.NewGuid.ToString
myDisplayColour = Colors.Blue
myDescription = "New Fabric"
End Sub
Public Sub New( _
ByVal newGUID As String,
ByVal newDisplayColour As System.Windows.Media.Color,
ByVal newDescription As String,
)
myGUID = newGUID
myDisplayColour = newDisplayColour
myDescription = newDescription
End Sub
Public Property FabricID() As String
Get
Return myGUID
End Get
Set(ByVal value As String)
myGUID = value
OnPropertyChanged(New PropertyChangedEventArgs("FabricID"))
End Set
End Property
Public Property DisplayColour() As System.Windows.Media.Color
Get
Return myDisplayColour
End Get
Set(ByVal value As System.Windows.Media.Color)
myDisplayColour = value
OnPropertyChanged(New PropertyChangedEventArgs("DisplayColour"))
Call myfrmMDI.pic3DView_Paint()
End Set
End Property
Public Property Description() As String
Get
Return myDescription
End Get
Set(ByVal value As String)
myDescription = value
OnPropertyChanged(New PropertyChangedEventArgs("Description"))
End Set
End Property
Apologies for the long reply!