Solved

Get the value of comboBox

Posted on 2012-03-27
4
435 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
[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
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

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