Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7845741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:20:48+00:00 2026-06-02T17:20:48+00:00

I would like to bind a checkbox list to a collection of enum values

  • 0

I would like to bind a checkbox list to a collection of enum values in WPF.
The enum is not [Flags].

Context:
It is for filtering a datagrid, in which each item has a instance of my enum.
It doesn’t necessarily need to bind to an List, a fixed size collection of would work as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:20:49+00:00Added an answer on June 2, 2026 at 5:20 pm

    Assuming you want to bind to all possible values of your enum, you can do it with an ObjectDataProvider.
    Declare this in your resources (Window.Resources or App.Resources etc.):

        <ObjectDataProvider x:Key="enumValues" MethodName="GetValues" ObjectType="{x:Type sys:Enum}">
            <ObjectDataProvider.MethodParameters>
                <x:Type TypeName="local:TestEnum"/>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    

    This basically represents a call to Enum.GetValues(typeof(TestEnum)) and exposes it as a data source.
    Note: You need to declare the namespaces sys and local before, where sys is clr-namespace:System;assembly=mscorlib and local is the namespace of your enum.

    Once you have that, you can use that ObjectDataProvider as a Binding source just like anything else, for example:

    <ListBox ItemsSource="{Binding Source={StaticResource enumValues}}"/>
    

    The non-declarative way of doing this is just assigning that in code:

    someListBox.ItemsSource = Enum.GetValues(typeof(TestEnum));
    

    For binding the selected items, unfortunately the SelectedItems property cannot be set from Xaml, but you can use the SelectionChanged event:

    <ListBox Name="lb" ItemsSource="{Binding Source={StaticResource enumValues}}" SelectionMode="Multiple" SelectionChanged="lb_SelectionChanged"></ListBox>
    

    and then set the property on your ViewModel (or whatever you use) in the event:

    private void lb_SelectionChanged(object sender, SelectionChangedEventArgs e) {
        viewModel.SelectedValues = lb.SelectedItems.OfType<TestEnum>().ToList();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to bind List of my class to CombpBox in WPF. I
I would like to bind C-` (control-backquote) but I could not do it. The
In a WPF based project I would like to bind the content of a
Hi I have a text field which I would like to bind to a
I would like to bind a list control (like a ListView) in a view
I have written a software which I would like to bind to mac. Is
I would like to find an example of a WPF Datagrid that has row
I would like to bind the same event to a list of anchor link.
I have a Silverlight (WP7) project and would like to bind an enum to
I have a WPF combobox that I would like to bind to an observable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.