c# - WPF data binding to dictionary with enum key -



c# - WPF data binding to dictionary with enum key -

i have solution couple of projects. in 1 project, model has enum called modelenum.

then in wpf project have viewmodel has dictionary.

and in viewmodel have valuesdictionary setup as:

private dictionary<modelenum, string> _valuesdictionary = new dictionary<modelenum, string>(); public dictionary<modelenum, string> valuesdictionary { { homecoming _valuesdictionary; } set { _valuesdictionary = value; onpropertychanged(_valuesdictionary); } }

in xaml have:

xmlns:model="clr-namespace:model.data;assembly=model" ... <textbox text="{binding path=valuesdictionary[(model:modelenum)modelenum.enum1].value}" horizontalalignment="left" height="29" margin="90,82,0,0" textwrapping="wrap" verticalalignment="top" width="50"/>

the next xaml snippet:

(model:modelenum)modelenum.enum1

is giving me error "parameter type mismatch." i'm confused because thought casting enum type expecting. referenced this question seek no luck.

replace

(model:modelenum)modelenum.enum1].value

with

(model:modelenum)enum1]

then try. hope work.

c# wpf xaml dictionary enums

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -