[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Get the value of comboBox

Posted on 2012-03-27
4
Medium Priority
?
450 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 501 total points
ID: 37772794
is it not just cmbdescription.value
0
 
LVL 5

Assisted Solution

by:Aruiz04
Aruiz04 earned 498 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 501 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Integration Management Part 2
Suggested Courses

831 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