WPF data binding to dictionary with enum key

前端 未结 2 1014
小鲜肉
小鲜肉 2021-01-07 06:37

I have a solution with a couple of projects. In one project, is my model that has an enum called ModelEnum.

Then in my WPF project I have a ViewModel which has a Dic

2条回答
  •  旧巷少年郎
    2021-01-07 07:24

    Just to add to the potential pitfalls with this, I had issues binding without the explicit "Path="

    i.e.

    {Binding ValuesDictionary[(model:ModelEnum)Enum1]}
    

    doesn't work, but:

    {Binding Path=ValuesDictionary[(model:ModelEnum)Enum1]}
    

    works as expected, although the designer (or maybe ReSharper) still complains about syntax errors.

提交回复
热议问题