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
515
XamComboEditor and UnboundField
posted

Hello,

please have a look at this example. I tried to extract a problem from my real apps, but actually get different results. There seems to be a basic problems doing so:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<

 

 

 

Window x:Class

="MainWindow"

 

 

 

xmlns

="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

 

 

 

xmlns:x

="http://schemas.microsoft.com/winfx/2006/xaml"

 

 

 

xmlns:my

="clr-namespace:WpfApplication1"

 

 

 

Title="MainWindow" Height="350" Width="525"

 

 

 

xmlns:igDP

="http://infragistics.com/DataPresenter"

 

 

 

xmlns:igEditors

="http://infragistics.com/Editors">

 

 

 

 

<Grid

>

 

 

 

 

<igDP:XamDataGrid Name

="XamDataGrid1" >

 

 

 

 

<igDP:XamDataGrid.DataSource

>

 

 

 

 

<my:CRecords

/>

 

 

 

 

</igDP:XamDataGrid.DataSource

>

 

 

 

 

<igDP:XamDataGrid.FieldLayouts

>

 

 

 

 

<igDP:FieldLayout

>

 

 

 

 

<igDP:FieldLayout.Settings

>

 

 

 

 

<igDP:FieldLayoutSettings AutoGenerateFields

="False"/>

 

 

 

 

</igDP:FieldLayout.Settings

>

 

 

 

 

<igDP:UnboundField BindingPath

="DynEnumItem.Label"

 

 

 

BindingMode

="TwoWay">

 

 

 

 

<igDP:UnboundField.Settings

>

 

 

 

 

<igDP:FieldSettings EditorType

="igEditors:XamComboEditor"

 

 

 

AllowEdit

="True"

 

 

 

AllowGroupBy="True"

 

 

 

AllowRecordFiltering="True"

 

 

 

SupportDataErrorInfo

="True"

 

 

 

>

 

 

 

 

<igDP:FieldSettings.EditorStyle

>

 

 

 

 

<Style TargetType

="igEditors:XamComboEditor">

 

 

 

 

<Setter Property

="ItemsSource"

 

 

 

Value="{Binding DataItem.DynEnumItemValues}">

 

 

 

 

</Setter

>

 

 

 

 

<Setter Property

="SelectedItem"

 

 

 

Value="{Binding DataItem.DynEnumItem}">

 

 

 

 

</Setter

>

 

 

 

 

<Setter Property

="DisplayMemberPath"

 

 

 

Value

="Label">

 

 

 

 

 

</Setter

>

 

 

 

 

</Style

>

 

 

 

 

</igDP:FieldSettings.EditorStyle

>

 

 

 

 

 

</igDP:FieldSettings

>

 

 

 

 

</igDP:UnboundField.Settings

>

 

 

 

 

 

</igDP:UnboundField

>

 

 

 

 

</igDP:FieldLayout

>

 

 

 

 

</igDP:XamDataGrid.FieldLayouts

>

 

 

 

 

</igDP:XamDataGrid

>

 

 

 

 

</Grid

>

</

 

 

 

Window

>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Imports

 

 

 

System.ComponentModel

Class

 

 

 

MainWindow

End

 

 

 

Class

 

Public

 

 

 

Class

CRecords

 

 

 

Implements IEnumerable(Of CRecord

)

 

 

 

Private Items As IEnumerable(Of CRecord) = New CRecord() {New CRecord

()}

 

 

 

Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of CRecord) Implements System.Collections.Generic.IEnumerable(Of CRecord

).GetEnumerator

 

 

 

Return Me

.Items.GetEnumerator

 

 

 

End

Function

 

 

 

Private Function GetEnumerator1() As System.Collections.IEnumerator Implements System.Collections.IEnumerable

.GetEnumerator

 

 

 

Return Me

.GetEnumerator

 

 

 

End

Function

End

 

 

 

Class

 

Public

 

 

 

Class

CRecord

 

 

 

Implements

INotifyPropertyChanged

 

 

 

Private Sub DebugPrint(ByVal aMsg As String

)

 

 

 

Debug

.Print(aMsg)

 

 

 

End

Sub

 

 

 

Public Property DynEnumItem As

CDynEnumItem

 

 

 

Get

 

 

 

If Me.DynEnumItemM Is Nothing Then Me.DynEnumItemM = Me

.DynEnumItemValues.ElementAt(1)

 

 

 

Me.DebugPrint("DynEnumItem.Get: Label='" & Me.DynEnumItemM.Label & "'"

)

 

 

 

Return Me

.DynEnumItemM

 

 

 

End

Get

 

 

 

Set(ByVal value As CDynEnumItem

)

 

 

 

If value Is Nothing

Then

 

 

 

Me.DebugPrint("DynMenuItem.Set(Nothing)"

)

 

 

 

Else

 

 

 

Me.DebugPrint("DynMenuItem.Set(Label='" & value.Label & "')"

)

 

 

 

End

If

 

 

 

' If value Is Nothing Then value = Me.DynEnumItemValues.ElementAt(0)

 

 

 

Try

 

 

 

If value Is Nothing Then Throw New

ArgumentNullException

 

 

 

Me

.DynEnumItemM = value

 

 

 

Me.PropertyChangedRaise("DynEnumItem"

)

 

 

 

Catch ex As

Exception

 

 

 

Me

.DebugPrint(ex.Message)

 

 

 

Throw

ex

 

 

 

End

Try

 

 

 

End

Set

 

 

 

End

Property

 

 

 

Private DynEnumItemM As

CDynEnumItem

 

 

 

Public ReadOnly Property DynEnumItemValues As IEnumerable(Of CDynEnumItem

)

 

 

 

Get

 

 

 

If Me.DynEnumItemValuesM Is Nothing Then Me.DynEnumItemValuesM = New CDynEnumItem() {New CDynEnumItem(""), New CDynEnumItem("A"), New CDynEnumItem("B"

)}

 

 

 

Return Me

.DynEnumItemValuesM

 

 

 

End

Get

 

 

 

End

Property

 

 

 

Private DynEnumItemValuesM As IEnumerable(Of CDynEnumItem

)

 

 

 

 

Public Event PropertyChanged(ByVal sender As Object, ByVal e As System.ComponentModel.PropertyChangedEventArgs) Implements System.ComponentModel.INotifyPropertyChanged

.PropertyChanged

 

 

 

Private Sub PropertyChangedRaise(ByVal aPropertyName As String

)

 

 

 

RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs

(aPropertyName))

 

 

 

End

Sub

End

 

 

 

Class

 

Public

 

 

 

Class

CDynEnumItem

 

 

 

Friend Sub New(ByVal aLabel As String

)

 

 

 

Me

.Label = aLabel

 

 

 

End

Sub

 

 

 

Public Property Label As

String

End

 

 

 

Class

 

 

 

 

Parents
No Data
Reply
  • 138253
    Offline posted

    Hello,

    It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. I have been looking into your post and the code you provided and I created a sample project for you using your code. Basically I set the XamComboEditor’s ValuePath to your underlying object’s Label Property and now everything works as expected.

    Feel free to write me if you have further questions.

    WpfApplication1.zip
Children
No Data