Click here to Skip to main content
12,357,870 members (72,614 online)
Click here to Skip to main content
Add your own
alternative version

Stats

10.4K views
Posted

Silverlight combobox without items source with a bound selected value

, 8 Sep 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
A simple combo box that will have predefined items but the selected value bound to a property from our View Model.

Sometimes we just need a simple combo box that will have predefined items but the selected value must be bound to a property from our View Model. The XAML below is a simple approach to resolve the task:

<combobox>
    Width="220"
    SelectedValue="{Binding Path=Employee.Gender, Mode=TwoWay}"
    SelectedValuePath="Content">

The trick is to set the SelectedValuePath to the Content and bind the SelectedValue.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Ian Landicho
Team Leader
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160621.1 | Last Updated 8 Sep 2011
Article Copyright 2011 by Ian Landicho
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid