Getting SelectedValue from Wpf Combobox

Hi, i don't know why this seemed not easy but here is how it goes

Your XAML for the WPF Combo

<ComboBox Name="ddlApplication" DisplayMemberPath="AppName" SelectedValuePath="ID"  SelectedItem="App" Margin="92.709,56,220.46,0" VerticalAlignment="Top" Height="22.96" SelectionChanged="ddlApplication_SelectionChanged" />

Then you can easily bind a IList<YourObject> like this

  ddlApplication.ItemsSource = list;

            if (ddlApplication.HasItems)

            {

                ddlApplication.SelectedIndex = 0;

            }

and getting the selected value is easy as

 YourObject obj =  (YourObject)ddlApplication.SelectedItem;

            this.Title = obj .ID.ToString();

Done!  happy xamiling 

Published Tue, Nov 10 2009 3:41 PM by Adel Khalil
Filed under: , ,

Comments

# Home Improvement

Thursday, June 28, 2012 5:26 AM by Home Improvement

You're an incredibly great inspiration to many people. I acquire a significant amount of ideas right here.

# Home Improvement

Thursday, June 28, 2012 5:27 AM by Home Improvement

I’ll come back to read of you more upcoming posts. Have a great day!

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Please add 1 and 7 and type the answer here: