Solved

Get the value of comboBox

Posted on 2012-03-27
4
428 Views
Last Modified: 2012-06-21
How to get the value of comboBox? My code are as follows; In XAML I have this

 <ComboBox Height="23" Name="cmbDescription" Width="155" HorizontalAlignment="Left"
                              Margin="5,0,0,0" Grid.Row="0" Grid.Column="3"
                              Foreground="Red" FontWeight="Bold">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Description}" />
                    </StackPanel>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>

I want to read it to MessageBox Command as follows

MessageBox.Show(cmbDescription???);  How?
0
Comment
Question by:Whing Dela Cruz
4 Comments
 
LVL 9

Assisted Solution

by:OCDan
OCDan earned 167 total points
ID: 37772794
is it not just cmbdescription.value
0
 
LVL 5

Assisted Solution

by:Aruiz04
Aruiz04 earned 166 total points
ID: 37772870
You have to convert the selected item to the object type that you are binding ie:

let say your object is Product and has the property named Description

so you convert like this

Product p = (Product)combobox.SelectedItem;

MessageBox.Show(p.Description);
0
 
LVL 21

Accepted Solution

by:
masterpass earned 167 total points
ID: 37774281
try,

cmbDescription.Selection.Value.ToString() ;

hope this helps!
0
 

Author Closing Comment

by:Whing Dela Cruz
ID: 37791908
Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

911 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

16 Experts available now in Live!

Get 1:1 Help Now