Solved

ComboBox issue with WPF

Posted on 2009-07-08
1
862 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

752 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