Solved

Get the value of comboBox

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Summernote and form validation 10 47
Linq help 1 17
Object Oriented Best Practice 5 35
C# DataGridView_RowsAdded event not firing 1 40
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 article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

11 Experts available now in Live!

Get 1:1 Help Now