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 8935933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:06:07+00:00 2026-06-15T10:06:07+00:00

I’m attempting to databind to an entry in a dictionary where the key is

  • 0

I’m attempting to databind to an entry in a dictionary where the key is the enum. I’ve consulted this question, but the answer doesn’t work for me. Here are the non-boilerplate parts of my code:


SomePage.xaml:

<!-- Here I try all the ways I can think of. None of them produce any text -->
<TextBlock Text="{Binding Data[0]}" />
<TextBlock Text="{Binding Data[EnumValueA]}" />
<TextBlock Text="{Binding Data[SomeEnum.EnumValueA]}" />
<TextBlock Text="{Binding Data[(local:SomeEnum)EnumValueA]}" />
<TextBlock Text="{Binding Data[(local:SomeEnum)SomeEnum.EnumValueA]}" />

SomePage.xaml.cs:

public SomePage() {
    DataContext = new SomeVM();
    InitializeComponent();
}

SomeVM.cs:

public enum SomeEnum {
    EnumValueA, EnumValueB
}
public class SomeVM {
    public Dictionary<SomeEnum, int> Data { get; private set; }
    public SomeVM() {
        Data = new Dictionary<SomeEnum, int> {
            {SomeEnum.EnumValueA, 1337}
        };
    }
}

Why does this databinding not work?

  • 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-15T10:06:08+00:00Added an answer on June 15, 2026 at 10:06 am

    It is not possible. See http://msdn.microsoft.com/en-us/library/cc645024(v=vs.95).aspx#indexdata

    Indexer

    Indexers can be used for accessing properties in a path and obtaining
    items from a list, but with some notable restrictions:

    • List item
    • Numeric integer indexers are supported.
    • Beginning in Silverlight 4, string indexers are supported.
    • Only one-dimensional array indexing is supported.

    The type being indexed must implement or inherit IList. (List is
    accepted, because it implements IList. However IList is not
    accepted.)

    Numeric integer indexes are specified by declaring the zero-based
    index within bracket ([]) characters after the property name; for
    example, Employees[2].

    Property path evaluation first attempts to use integer indexing for a
    collection. If that indexing is not valid for the collection, then the
    information within [] is processed as a string. String indexing from a
    property path generally expects a collection / business object that is
    a dictionary with string keys. String indexing supports binding to
    dynamic data objects where the CLR structure of the data source can
    change, but the string keys represent a data contract that can still
    be bound to by a client UI.

    Validation uses indexers to access items of an attached property’s
    collection as part of its property path usage. The validation
    structure for the application can declare UI states within templates
    that are used only when validation errors are raised, and can then
    reference the active error objects in that context. For example, the
    following is a property path for a binding that accesses the first
    item in a Validation.Errors collection; the context of the property
    path is modified by RelativeSource so that the errors are checked only
    at run time on the applied template:

     <TextBlock Text="{Binding RelativeSource={RelativeSource
        TemplatedParent}, Path=(Validation.Errors)[0].Exception.Message }">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This could be a duplicate question, but I have no idea what search terms
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

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.