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
ComboBox in XamWebGrid DataTemplate
posted

 

Project Background

 

  • Silverlight Navigation Application
  • WCF
  • ADO.NET Entity Data Model
  • Domain Service Class

 

Facts About Project

 

  • Grid Binding is working fine
  • I have avoided any binding in grid from xmal instead have them in LoadData Function as seen in example below 
  • I have already went throw many infragistic examples
  • most of them have source as static resource similar to Infragistics Local Samples

 

Question

 

  • How to use ComboBox in XamWebGrid
  • it should have biding behind code similar to binding of < IngredientTypeComboEditor > in example below
  • Should not use Static Resource

 

XAML CODE:

 

 <igCombo:XamWebComboEditor Name="IngredientTypeComboEditor"  />

<igGrid:XamWebGrid Name="grdList">

 

            <igGrid:XamWebGrid.Columns>

                <igGrid:TextColumn Key="Code" HeaderText="Code" Width="Auto" MinimumWidth="20" />

                <igGrid:TextColumn Key="TitleAR" HeaderText="Name Arabic" Width="Auto" MinimumWidth="150" />

                <igGrid:TextColumn Key="TitleEN" HeaderText="Name English" Width="Auto" MinimumWidth="150" />

                <igGrid:TemplateColumn.ItemTemplate>

                        <DataTemplate>

                             <TextBlock Text="{Binding Path=???, Source={???}}" />                        </DataTemplate>

                    </igGrid:TemplateColumn.ItemTemplate>

 

                     <igGrid:TemplateColumn.EditorTemplate>

                        <DataTemplate>

                            <ComboBox Name="ComboIngredientType" ItemsSource="{Binding ???}" />

                        </DataTemplate>

                </igGrid:TemplateColumn.EditorTemplate> 

            </igGrid:TemplateColumn>

</igGrid:XamWebGrid>

VB CODE:

Dim SRV As New DomainService1

Private Sub LoadData()

Me.grdList.ItemsSource = SRV.Ingredients

        Me.grdList.ItemsSource = SRV.Ingredients

        SRV.Load(SRV.GetIngredientsQuery)

        Me.IngredientTypeComboEditor.ItemsSource = SRV.D_IngredientTypes

        Me.IngredientTypeComboEditor.DisplayMemberPath = "TitleEN"

        SRV.Load(SRV.GetD_IngredientTypeQuery)

End Sub

 

Parents
  • 40030
    Offline posted

    Hi, 

    The DataContext of the DataTemplate properties of a TemplateColumn are the data for the row, in which a cell represents.  So, in the ItemTemplate, if you have a property that represents an IngredientType on your Ingredient object, then you would just set that has the Path. And there would be no need to set the Source, as the DataContext would be your source. 

    As for your ComboBox's ItemSource, you should make a static resource and set that as the ItemsSource for your Combobox, as that would be the simplest approach. If that isn't possible, you can use the CellEnteredEditMode event and and check that your in your TemplateColumn, grab the editor ,cast it as a ComboBox and set the Itemssource. 

      void DataGrid1_CellEnteredEditMode(object sender, EditingCellEventArgs e)

            {

                if(e.Cell.Column.Key == "myTempCol")

                {

                    ((ComboBox)e.Editor).ItemsSource = myItemsSource;

                }

            }

    -SteveZ

     

Reply Children