Don't say anything, look at the code first
Enumeration:
namespace wpfapptest{ publicenum Week { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }}
Page:
<Windowx:class= "Wpfapptest.mainwindow"xmlns= "Http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x= "Http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d= "http://schemas.microsoft.com/expression/blend/2008"XMLNS:MC= "http://schemas.openxmlformats.org/markup-compatibility/2006"Xmlns:sys= "Clr-namespace:system;assembly=mscorlib"xmlns:local= "Clr-namespace:wpfapptest"mc:ignorable= "D"Title= "MainWindow"Height= " the"Width= "525"> <Grid> <grid.resources> <ObjectDataProviderx:key= "Nameweek"MethodName= "GetNames"ObjectType="{x:type Sys:enum}"> <objectdataprovider.methodparameters> <x:typeTypeName= "Local:week"/> </objectdataprovider.methodparameters> </ObjectDataProvider> <ObjectDataProviderx:key= "Valueweek"MethodName= "GetValues"ObjectType="{x:type Sys:enum}"> <objectdataprovider.methodparameters> <x:typeTypeName= "Local:week"/> </objectdataprovider.methodparameters> </ObjectDataProvider> </grid.resources> <ComboBoxSelectedValue="{Binding Selectedweek}"ItemsSource="{Binding Source={staticresource Nameweek}}"HorizontalAlignment= "Left"Height= " the"Margin= "38,40,0,0"VerticalAlignment= "Top"Width= "Max"/> <ComboBoxSelectedValue="{Binding Selectedweek}"ItemsSource="{Binding Source={staticresource Valueweek}}"HorizontalAlignment= "Left"Height= " the"Margin= "288,40,0,0"VerticalAlignment= "Top"Width= "Max"/> </Grid></Window>
Background:
usingSystem.Windows;namespacewpfapptest{/// <summary> ///the interactive logic of MainWindow.xaml/// </summary> Public Partial classMainwindow:window { PublicMainWindow () {InitializeComponent (); DataContext= This; } PublicWeek Selectedweek {Get{return(Week) GetValue (selectedweekproperty);} Set{SetValue (selectedweekproperty, value);} } Public Static ReadOnlyDependencyProperty Selectedweekproperty =Dependencyproperty.register ("Selectedweek",typeof(Week),typeof(MainWindow),NewPropertyMetadata (default(Week))); }}
Before looking at the online examples are used GetNames reflection, but tied SelectedValue but only from the interface to the backstage, later saw the code of the enum to understand to use GetValues
System.Enum:
Public Static string [] GetNames (Type enumtype); Public Static Array GetValues (Type enumtype);
WPF ComboBox Binding Enum