Click here to Skip to main content
Click here to Skip to main content

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

Comments and Discussions

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