Solved

ComboBox issue with WPF

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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

617 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