Solved

ComboBox issue with WPF

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…

749 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