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

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -