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
115
Problem Binding XamComboEditor
posted

I have a problem creating a xamcomboEditor in my datagrid and would like to help. The thing is I can do the binding in the event of xamComboEditor initialized and it fills the ItemsSource correctly, but the problem is that when I select an item and give ok and back on the screen the selectedItem or Text property of xamComboEditor is not correctly

 

Code XAML:

<igDP:UnboundField Label="Recurso1" Name="Resource">

                                    <igDP:Field.Settings>

                                        <igDP:FieldSettings>

                                            <igDP:FieldSettings.CellValuePresenterStyle>

                                                <Style TargetType="{x:Type igDP:CellValuePresenter}">

                                                    <Setter Property="Template">

                                                        <Setter.Value>

                                                            <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

                                                                <igEdit:XamComboEditor IsEditable="False"

                                                                  Initialized="ComboboxResourceItemsSource"    

                                                                  SelectedItemChanged="ChangeResource" Theme="Office2k7Blue"/>

                                                            </ControlTemplate>

                                                        </Setter.Value>

                                                    </Setter>

                                                </Style>

                                            </igDP:FieldSettings.CellValuePresenterStyle>

                                        </igDP:FieldSettings>

                                    </igDP:Field.Settings>

                                </igDP:UnboundField>

 

Code Behind:

Private Sub ComboboxResourceItemsSource(ByVal sender As Object, ByVal e As EventArgs)

        Dim comboboxResource As XamComboEditor = sender

        Dim resourcesCollection As New ObservableCollection(Of Resource)((From temp In ContextCurrent.Resources _

        Select temp))

        Dim BindingTemp As New Binding()

        Dim teste3 As New PropertyPath("Content")

        BindingTemp.Path = teste3

        BindingTemp.Mode = BindingMode.TwoWay

        BindingTemp.Source = GanttChartCurrent.AssignableResourceManager.Items     

        comboboxResource.ItemsSource = GanttChartCurrent.AssignableResourceManager.Items 

        comboboxResource.DisplayMemberPath = "Content"        

        comboboxResource.SetBinding(XamComboEditor.TextProperty, BindingTemp)

    End Sub

 

Parents
No Data
Reply
  • 69686
    posted

    Hello,

    There are couple of issues that come up in my mind when looking at this code:

    1. You do not have to retemplate the whole CellValuePresenter just to put a XamComboEditor inside the cell. You can just set the EditorType property of the UnboundField's Settings to XamComboEditor.

    2. You can create a style for the XamComboEditor and assign it at the EditorStyle property of the Unboundfield's settings. There you can set the ItemsProvider and the ItemsSource( which I believe you get it as an resource)

    3. You have not bound the SelectedItem property of the XamComboEditor to the Cell's value. However, if you go with 1), this will be done for you automatically.

Children
No Data