Get Days using Enum in WPF

First of all make a new  project using WPF. and drag and drop a combobox on window.

<Window x:Class="WPFEnumSample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dayOfWEEK="clr-namespace:WPFEnumSample"
        xmlns:System="clr-namespace:System;assembly=mscorlib"        
        Title="MainWindow" Height="200" Width="300">
        <Window.Resources>        
            <ObjectDataProvider x:Key="weekDays" MethodName="GetValues" ObjectType="{x:Type System:Enum}" >            
                <ObjectDataProvider.MethodParameters>
                    <x:Type TypeName="dayOfWEEK:DaysOfTheWeek"/>
                </ObjectDataProvider.MethodParameters>
            </ObjectDataProvider>
        </Window.Resources>
        <Grid>
            <TextBlock Margin="49,26,84,115" Height="20" Text="Select the day of the week:"/>
            <ComboBox Margin="48,61,32,80" ItemsSource="{Binding Source={StaticResource weekDays}}" Height="20" />
        </Grid>
</Window>


Now run the project.

dayofweek.JPG
Ebook Download
View all
Learn
View all