Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ComboBox issue with WPF

Posted on 2009-07-08
1
Medium Priority
?
867 Views
Last Modified: 2013-11-26
I have a combo box for a WPF windows application. The combo box is bound to some data on code and I created a DataTemplate to display multiple columns in the drop down box (see code). However, I am having an issue retrieving the selected value from the combo box. I have tried cboCustomers.SelectedItem, cboCustomers.SelectedValue, cboCustomers.SelectedBoxItem all to no avail. How do I retrieve this value?

MT
<ComboBox ItemsSource="{Binding}" SelectedValuePath="CustomerID" Height="23" Margin="12,0,19,52" Name="cboCustomers" VerticalAlignment="Bottom" Width="675">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding CustomerID}" Visibility="Hidden"/>
                        <TextBlock Text="{Binding CustomerName}" Width="250"/>
                        <TextBlock Text="{Binding CustomerState}" Width="25"/>
                        <TextBlock Text="{Binding CustomerAddress1}" Width="175"/>
                        <TextBlock Text="{Binding CustomerAddress2}" Width="150"/>
                        <TextBlock Text="{Binding CustomerPhoneBusiness}" Width="75"/>
                    </StackPanel>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

Open in new window

0
Comment
Question by:Chris_Yancey
1 Comment
 

Accepted Solution

by:
Chris_Yancey earned 0 total points
ID: 24825862
I think I figured it out. cboCustomers.SelectedItem actually returns back a DataRowView object which I can then drill down to find the appropriate value.
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question