Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6999715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:34:39+00:00 2026-05-27T20:34:39+00:00

I have a scenario that does not seem to be covered in any of

  • 0

I have a scenario that does not seem to be covered in any of the other similar questions (most of which are unanswered anyways).

Here goes:

I have the following items to work with:

1) A WCF Service that returns a very complex data contract with over 100 properties. I do not wish to create a ViewModel of this object as I don’t want to have to maintain over 100 properties unless absolutely necessary.

2) I have a Silverlight UserControl that has this data contract defined as a Resource:

<UserControl.Resources>
    <DieEstimateService:DieEstimateContract x:Key="Die" />
</UserControl.Resources>

3) I have a datagrid that binds to a collection of the Die called Die.DieMetalforming. This collection is an Array of DieMetalformingContract objects. There are two columns to display from this collection, the DiePunchFunctionDescription and the DiePunchConstructionDescription properties. The DiePunchFunctionDescription has a corresponding key properties called DiePunchFunctionUID and likewise, the DiePunchConstructionDescription has a key property called DiePunchConstructionUID. When the grid is in display mode, it uses TextBlocks to display the DiePunchFunctionDescription and DiePunchConstructionDescription fields. The DataGrid is bound to the Die.DieMetalforming array via code behind as such:

dgDieMetalforming.ItemsSource = Die.DieMetalformings;

4) When the grid is in edit mode, there are comboboxes for the DiePunchFunction and DiePunchConstruction columns, both of which are to be bound to the collections of metadata from the Die object. These collections are named DiePunchFunctionFields and DiePunchConstructionFields. Both collections are arrays of StandardCostFieldContract objects (they just have different data in them based on the type of field). The StandardCostFieldContract has a display property of “FieldDescription” and a key property of “StandardCostFieldUID”.

5) Finally, the datagrid contains a third column on the Quantity property of the DieMetalformingContract. In normal mode this is a TextBlock and in edit mode this is a TextBox. This property is working as intended for two-way databinding.

The datagrid binds correctly to the datasource as evidenced by the correct functionality of the TextBlocks and the TextBox of the Quantity field. However, I cannot get the comboboxes to load their data from the DiePunchFunctions or DiePunchConstructions arrays. I’ve ready a dozen articles on the subject and tried every permutation of ItemSources binding I could find but nothing seems to work. Here’s my datagrid definition:

    <sdk:DataGrid AutoGenerateColumns="False" Height="167" HorizontalAlignment="Stretch" Margin="6,255,6,0" 
                  Name="dgDieMetalforming" VerticalAlignment="Top" Width="Auto" Grid.ColumnSpan="4" 
                  SelectionMode="Single" TabNavigation="Local">
    <sdk:DataGrid.Columns>
        <sdk:DataGridTemplateColumn CanUserReorder="False" CanUserResize="False" 
            CanUserSort="False" Header="Punch/Die Function" Width="Auto" >
            <sdk:DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding DiePunchFunctionDescription}" Margin="4" />
                </DataTemplate>
            </sdk:DataGridTemplateColumn.CellTemplate>
            <sdk:DataGridTemplateColumn.CellEditingTemplate>
                <DataTemplate>
                    <ComboBox Name="ddlDiePunchFunction" ItemsSource="{Binding 
                     Path=Die.DiePunchFunctionFields, Mode=OneWay}" 
                     SelectedItem="{Binding Path=DiePunchFunctionUID, Mode=TwoWay}" 
                     DisplayMemberPath="FieldDescription" 
                     SelectedValuePath="StandardCostFieldUID" />
                </DataTemplate>
            </sdk:DataGridTemplateColumn.CellEditingTemplate>
        </sdk:DataGridTemplateColumn>
        <sdk:DataGridTemplateColumn CanUserReorder="False" CanUserResize="False" 
            CanUserSort="False" Header="Punch/Die Construction" Width="Auto" >
            <sdk:DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding DiePunchConstructionDescription}" Margin="4" />
                </DataTemplate>
            </sdk:DataGridTemplateColumn.CellTemplate>
            <sdk:DataGridTemplateColumn.CellEditingTemplate>
                <DataTemplate>
                    <ComboBox Name="ddlDiePunchFunction" ItemsSource="{Binding 
                     Path=Die.DiePunchConstructionFields, Mode=OneWay}" 
                     SelectedItem="{Binding Path=DiePunchConstructionUID, Mode=TwoWay}" 
                     DisplayMemberPath="FieldDescription" 
                     SelectedValuePath="StandardCostFieldUID" />
                </DataTemplate>
            </sdk:DataGridTemplateColumn.CellEditingTemplate>
        </sdk:DataGridTemplateColumn>
        <sdk:DataGridTemplateColumn CanUserReorder="False" CanUserResize="False" 
             CanUserSort="False" Header="Quantity" Width="Auto" >
            <sdk:DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Quantity}" Margin="4" />
                </DataTemplate>
            </sdk:DataGridTemplateColumn.CellTemplate>
            <sdk:DataGridTemplateColumn.CellEditingTemplate>
                <DataTemplate>
                    <TextBox Name="txtQuantity" Text="{Binding Quantity, Mode=TwoWay}" />
                </DataTemplate>
            </sdk:DataGridTemplateColumn.CellEditingTemplate>
        </sdk:DataGridTemplateColumn>
    </sdk:DataGrid.Columns>
</sdk:DataGrid>

I’ve spent way too much time on this already and it’s reached a point where I need to rework the whole idea before billing for any more time on this problem. If you can recommend a course of action that will make the comboboxes bind to their itemsources I would be eternally grateful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:34:40+00:00Added an answer on May 27, 2026 at 8:34 pm

    I finally said “SCREW IT” to databinding and went with codebehind events to bind the comboboxes. The new grid looks like this (I’ve added some ancillary functionality since posting the question).

        <sdk:DataGrid AutoGenerateColumns="False" Height="167" HorizontalAlignment="Stretch" Margin="6,255,6,0" 
                      Name="dgDieMetalforming" VerticalAlignment="Top" Width="Auto" Grid.ColumnSpan="4" 
                      SelectionMode="Single" TabNavigation="Local">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTemplateColumn CanUserReorder="False" CanUserResize="False" 
                                            CanUserSort="False" Header="Punch/Die Function" Width="Auto" >
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding DiePunchFunctionDescription}" Margin="4" />
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                    <sdk:DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox Name="ddlDiePunchFunction" 
                                      SelectionChanged="ddlDiePunchFunction_SelectionChanged" 
                                      Loaded="ddlDiePunchFunction_Loaded" 
                                      SelectedItem="{Binding Path=DiePunchFunctionUID, Mode=TwoWay}" 
                                      DisplayMemberPath="FieldDescription" 
                                      SelectedValuePath="StandardCostFieldUID" />
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellEditingTemplate>
                </sdk:DataGridTemplateColumn>
                <sdk:DataGridTemplateColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False" 
                                            Header="Punch/Die Construction" Width="Auto" >
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding DiePunchConstructionDescription}" Margin="4" />
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                    <sdk:DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <ComboBox Name="ddlDiePunchConstruction" 
                                      SelectionChanged="ddlDiePunchConstruction_SelectionChanged" 
                                      Loaded="ddlDiePunchFunction_Loaded" 
                                      SelectedItem="{Binding Path=DiePunchConstructionUID, Mode=TwoWay}" 
                                      DisplayMemberPath="FieldDescription" 
                                      SelectedValuePath="StandardCostFieldUID" />
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellEditingTemplate>
                </sdk:DataGridTemplateColumn>
                <sdk:DataGridTemplateColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False" 
                                            Header="Quantity" Width="Auto" >
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Quantity}" Margin="4" />
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                    <sdk:DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <TextBox Name="txtQuantity" Text="{Binding Quantity, Mode=TwoWay}" />
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellEditingTemplate>
                </sdk:DataGridTemplateColumn>
                <sdk:DataGridTemplateColumn CanUserReorder="false" CanUserResize="False" CanUserSort="False" 
                                            Header="" Width="Auto">
                    <sdk:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Name="btnDelete" Click="btnDelete_Click">
                                <TextBlock>delete</TextBlock></Button>
                        </DataTemplate>
                    </sdk:DataGridTemplateColumn.CellTemplate>
                </sdk:DataGridTemplateColumn>
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>
    

    The codebehind looks like this.

    private void ddlDiePunchFunction_Loaded(object sender, RoutedEventArgs e)
    {
        var src = sender as ComboBox;
        if (src.IsNotNull())
        {
            var data = src.DataContext as DieMetalformingContract;
            switch (src.Name)
            {
                case "ddlDiePunchFunction":
                    src.ItemsSource = Die.DiePunchFunctionFields;
                    src.SelectedValue = data.DiePunchFunctionUID;
                    break;
                case "ddlDiePunchConstruction":
                    src.ItemsSource = Die.DiePunchConstructionFields;
                    src.SelectedValue = data.DiePunchConstructionUID;
                    break;
            }
        }
    }
    
    private void ddlDiePunchFunction_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        var src = sender as ComboBox;
        if (src.IsNotNull())
        {
            var data = src.DataContext as DieMetalformingContract;
            data.DiePunchFunctionUID = src.SelectedValue.ToNullableGuid() ?? Guid.Empty;
            data.DiePunchFunctionDescription = (from x in Die.DiePunchFunctionFields
                                                where x.StandardCostFieldUID == data.DiePunchFunctionUID
                                                select x.FieldDescription).FirstOrDefault();
        }
    }
    
    private void ddlDiePunchConstruction_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        var src = sender as ComboBox;
        if (src.IsNotNull())
        {
            var data = src.DataContext as DieMetalformingContract;
            data.DiePunchConstructionUID = src.SelectedValue.ToNullableGuid() ?? Guid.Empty;
            data.DiePunchConstructionDescription = (from x in Die.DiePunchConstructionFields
                                                where x.StandardCostFieldUID == data.DiePunchConstructionUID
                                                select x.FieldDescription).FirstOrDefault();
        }
    }
    

    Thanks to everyone who has read this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario I have a background worker in my application that runs off and does
I have a path defined: when /the admin home\s?page/ /admin/ I have scenario that
I have a scenario that looks like this: #include <algorithm> using namespace std; //
I have a scenario that my load balancer translates port 80 from outside into
I have a scenario that I haven't been able to solve: I'm toying around
I have a scenario that, I am creating dynamic html content and I need
I have a scenario that when I try to access a hash key using
I have a scenario outline table that looks like the following: Scenario Outline: Verify
Lets assume a scenario that i have a remote, a developer1 and a developer2.
My scenario is that I have some payment transaction data in MySQL and some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.