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
250
Different itemsources with a XamComboEditor on a cell
posted

I want to bind a XamComboEditor to a Cell, where each cell in a row has a different set of data in the combobox, in C# code.

 

I use a ComboBoxItemsProvider, Fieldsetting and style to set a fieldsetting of a particular cell, through the 'InitializeRecord' event.

But that settings is used for the hole column (or Field for that matter).

Conclusion i get the same data on every row (in de particular column).

In the XamComboEditor dependeny properties is a loaded event, is it possible though that to set the correct XamComboEditor data and how?

Parents
  • 69686
    posted

     Hi,

     You need to create a style for each cell with a XamComboEditor and set the data for it through the style. For example on one row I have two XamComboEditors - one for the status and one for the priority. So I create two styles for them:

     <Style x:Key="PriorityFieldStyle"
                           TargetType="{x:Type igEditors:XamComboEditor}">
                        <Setter Property="ItemsProvider">
                            <Setter.Value>
                                    <igEditors:ComboBoxItemsProvider
                  ItemsSource="{Binding Source={StaticResource PrioritiesXml}, XPath=/priorities/priority}"
                  DisplayMemberPath="@text"
                  ValuePath="@id"/>                            
                            </Setter.Value>
                        </Setter>
                    </Style>

    and

    <Style x:Key="StatusFieldStyle"
                           TargetType="{x:Type igEditors:XamComboEditor}">
                        <Setter Property="ItemsProvider">
                            <Setter.Value>
                                    <igEditors:ComboBoxItemsProvider
                  ItemsSource="{Binding Source={StaticResource StatusXml}, XPath=/stats/status}"
                  DisplayMemberPath="@text"
                  ValuePath="@id"/>                            
                            </Setter.Value>
                        </Setter>
                    </Style>



    The data comes from the XmlDataProvider -- like this:

    <XmlDataProvider x:Key="PrioritiesXml">
        <x:XData>
            <priorities xmlns="">
                <priority text="High"   id="0" />
                <priority text="Normal" id="2" />
                <priority text="Low"    id="1" />
            </priorities>
        </x:XData>
    </XmlDataProvider>

     

    <igDP:Field Name="State" Label="Status">
        <igDP:Field.Settings>

            <igDP:FieldSettings PropertyChanged="FieldSettings_PropertyChanged"  EditorStyle="{StaticResource StatusFieldStyle}" CellWidth="150"             LabelWidth="150" />

        </igDP:Field.Settings>
    </igDP:Field>


    <igDP:Field Name="PriorityLevel" Label="Priority">
        <igDP:Field.Settings>
             <igDP:FieldSettings EditorStyle="{StaticResource PriorityFieldStyle}" />
        </igDP:Field.Settings>
    </igDP:Field>

    There is also an example of this in the XamFeatureBrowser in the Control Composition section of the XamDataGrid samples. 

    Hope this helps. 

Reply Children