Bind ComboBox with Enum Type in WPF

In this article i will show you, How to Bind ComboBox with Enum properties.  Enum is a type, which is used to fix no of values like Sunday, Monday, Tuesday...etc.). By using XAML, you can add static resources for enumeration. In WPF We have a ObjectDataProvider for enumeration. Lets check the code.

XAML Code :

<Window x:Class="WpfApplication1212.Window2"
        Title="Window2" Height="300" Width="300">
        <ObjectDataProvider MethodName="GetValues" ObjectType="{x:Type codeg:Enum}" x:Key="myenu">
                <x:Type Type="local1:week1" />
        <ComboBox ItemsSource="{Binding Source={StaticResource myenu}}" />

Enumeration code 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WpfApplication1212
    class Order
    public enum week1
Bind ComboBox with Enum Type in WPF Bind ComboBox with Enum Type in WPF Reviewed by Jacob Lefore on April 27, 2016 Rating: 5

No comments