Solved

Get the value of comboBox

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

Suggested Solutions

Title # Comments Views Activity
Amazon S3 .Net error 5 41
WPF user control poped up from a window 1 35
Html split(text) Part2 6 21
add 'N to prepared ASP/VB insert statement 1 11
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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/…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

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