Solved

ComboBox issue with WPF

Posted on 2009-07-08
1
854 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now