This question is locked. New answers and comments are not allowed.
Hi, I'm trying to get this ComboBoxColumn working and I'm having a bit of trouble.
ConfigTypes is a property on my ViewModel that returns a list of KeyValuePair items which may be the problem here...
The items display in the ComboBox correctly, but I can't get the selected item to reflect the value of the ConfigType property.
Any idea what I'm doing wrong?
<telerik:GridViewComboBoxColumn Header="Config Type"
Width="100"
SortMemberPath="ConfigType" ShowDistinctFilters="True" ShowFilterButton="True" ShowFieldFilters="False" ItemsSource="{Binding ConfigTypes, Source={StaticResource ItemViewModel}}" DisplayMemberPath="Key" SelectedValueMemberPath="ConfigType" DataMemberBinding="{Binding ConfigType}"/>ConfigTypes is a property on my ViewModel that returns a list of KeyValuePair items which may be the problem here...
Public ReadOnly Property ConfigTypes Get Dim tmp = Mcpic.Core.Common.Converter.EnumToKeyValueList(ItemConfigType.Operational) Return tmp End Get End PropertyThe items display in the ComboBox correctly, but I can't get the selected item to reflect the value of the ConfigType property.
Any idea what I'm doing wrong?
3 Answers, 1 is accepted
0
Hi Barry ,
Please try the following :
In case this does not help , please paste me the ViewModel implementation so we can seek for the cause of the problem further.
Kind regards,
Pavel Pavlov
the Telerik team
Please try the following :
SelectedValueMemberPath="Value"In case this does not help , please paste me the ViewModel implementation so we can seek for the cause of the problem further.
Kind regards,
Pavel Pavlov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Barry
Top achievements
Rank 1
answered on 12 Mar 2012, 04:20 PM
Thanks for the quick reply. I had tried that and it does not work either.
The ViewModel is as follows:
And here is the ItemConfig class
The ViewModel is as follows:
Public Class TechDataItemViewModel Inherits EquipmentMgmtViewModelBase Implements IRegionContext Private regionManager As IRegionManager#Region " Events " Public Event Loaded()#End Region#Region " Constructors " Public Sub New() If Not IsDesignTime Then Me.regionManager = ServiceLocator.Current.GetInstance(Of IRegionManager)() 'Refresh() WireCommands() End If End Sub Public Sub New(src As ItemTechData) If Not IsDesignTime Then Me.regionManager = ServiceLocator.Current.GetInstance(Of IRegionManager)() Item = src Item.AcceptChanges() WireCommands() End If End Sub#End Region#Region " Properties " Public ReadOnly Property ConfigTypes Get Return Mcpic.Core.Common.Converter.EnumToKeyValueList(ItemConfigType.Operational) End Get End Property Public ReadOnly Property IsReadOnly As Boolean Get Return If(itemValue Is Nothing, False, itemValue.IsReadOnly) End Get End Property Private itemValue As ItemTechData Public Property Item() As ItemTechData Get Return itemValue End Get Private Set(ByVal value As ItemTechData) If value IsNot itemValue Then itemValue = value If itemValue IsNot Nothing Then AddHandler itemValue.PropertyChanged, AddressOf ItemPropertyChanged End If Refresh() MyBase.RaisePropertyChanged(BL.Props.Item) MyBase.RaisePropertyChanged(BL.Props.IsDirty) MyBase.RaisePropertyChanged(BL.Props.IsReadOnly) End If End Set End Property Private configValue As New TrackableCollection(Of ItemConfig) Public ReadOnly Property Configs() As TrackableCollection(Of ItemConfig) Get Return configValue End Get 'Set(ByVal value As TrackableCollection(Of ItemConfig)) ' If value IsNot configValue Then ' configValue = value ' MyBase.RaisePropertyChanged(BL.Props.Configs) ' MyBase.RaisePropertyChanged(BL.Props.IsDirty) ' End If 'End Set End PropertyAnd here is the ItemConfig class
<DataContract()> Public Class ItemConfig Inherits ModelBase Public Sub New() Me.AcceptChanges() End Sub#If SILVERLIGHT = 0 Then Public Sub New(src As Entities.ItemConfig) ItemConfigId = src.ItemConfigId Niin = src.Niin Length = src.Length Width = src.Width Height = src.Height Weight = src.Weight ConfigType = src.ConfigType CreatedDt = src.CreatedDt ModifiedDt = src.ModifiedDt CreatedId = Identifier.GetNewUser(src.CreatedId, src.CreatedName) ModifiedId = Identifier.GetNewUser(src.ModifiedId, src.ModifiedName) AcceptChanges() End Sub#End If Private itemConfigIdValue As Guid = Guid.Empty <DataMember(), Trackable()> Public Property ItemConfigId() As Guid Get Return itemConfigIdValue End Get Set(ByVal value As Guid) If itemConfigIdValue <> value Then itemConfigIdValue = value RaisePropertyChanged(BL.Props.ItemConfigId) End If End Set End Property Private niinValue As String = String.Empty <DataMember(), Trackable()> Public Property Niin() As String Get Return niinValue End Get Set(ByVal value As String) If niinValue <> value Then niinValue = value RaisePropertyChanged(BL.Props.Niin) End If End Set End Property Private heightValue As Double = 0 <DataMember(), Trackable()> Public Property Height() As Double Get Return heightValue End Get Set(ByVal value As Double) If heightValue <> value Then heightValue = value RaisePropertyChanged(BL.Props.Height) End If End Set End Property Private lengthValue As Double = 0 <DataMember(), Trackable()> Public Property Length() As Double Get Return lengthValue End Get Set(ByVal value As Double) If lengthValue <> value Then lengthValue = value RaisePropertyChanged(BL.Props.Length) End If End Set End Property Private widthValue As Double = 0 <DataMember(), Trackable()> Public Property Width() As Double Get Return widthValue End Get Set(ByVal value As Double) If widthValue <> value Then widthValue = value RaisePropertyChanged(BL.Props.Width) End If End Set End Property Private weightValue As Double = 0 <DataMember(), Trackable()> Public Property Weight() As Double Get Return weightValue End Get Set(ByVal value As Double) If weightValue <> value Then weightValue = value RaisePropertyChanged(BL.Props.Weight) End If End Set End Property Private configTypeValue As ItemConfigType = ItemConfigType.BareItem <DataMember(), Trackable()> Public Property ConfigType() As ItemConfigType Get Return configTypeValue End Get Set(ByVal value As ItemConfigType) If configTypeValue <> value Then configTypeValue = value RaisePropertyChanged(BL.Props.ConfigType) End If End Set End PropertyEnd ClassEnd Namespace0
Accepted
Hello Barry ,
Thanks for sending the code. I see that the ConfigType property used for the DataMemberBinding contains neither the value nor the key. It actually contains the whole keyvalue pair.
So let us try omitting the SelectedValueMemberPath setting.
Something like:
Greetings,
Pavel Pavlov
the Telerik team
Thanks for sending the code. I see that the ConfigType property used for the DataMemberBinding contains neither the value nor the key. It actually contains the whole keyvalue pair.
So let us try omitting the SelectedValueMemberPath setting.
Something like:
Copy Code <telerik:GridViewComboBoxColumn Header="Config Type" Width="100" SortMemberPath="ConfigType" ShowDistinctFilters="True" ShowFilterButton="True" ShowFieldFilters="False" ItemsSource="{Binding ConfigTypes, Source={StaticResource ItemViewModel}}" DisplayMemberPath="Key" DataMemberBinding="{Binding ConfigType}"/>Greetings,
Pavel Pavlov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>