Is there a way to bind a Dictionary in mvvmcross -
Is there a way to bind a Dictionary in mvvmcross -
i started using observable concurrentdictionary because it's threadsafe. face problem how bind list.
local:mvxbind="itemssource sourcedictionary"
obviously cannot work because item consists of keyvaluepair , not object itself.
local:mvxbind="itemssource sourcedictionary.values"
does not work. which, must admit, puzzles me. tried long shot , did converter :
public class sourcedictionaryvalueconverter : mvxvalueconverter<keyvaluepair<string, sourceclass >, sourceclass > { protected override sourceclass convert(keyvaluepair<string, sourceclass> value, type targettype, object parameter, cultureinfo culture) { homecoming value.value; } }
and bind
local:mvxbind="itemssource sourcedictionary, converter=sourcedictionary"
but didn't work. suppose asks ilist. there way bind listview dictionary?
you should able bind dictionary - or indeed ienumerable
.
if binding dictionary (rather values
) need write item bindings know keyvaluepair - e.g. might need bind key.name
rather name
.
however, dictionary's not notify listeners of changes - using dictionary using list - not using observablecollection. if want type of behaviour need write or find dictionary class implements inotifycollectionchanged.
mvvmcross
Comments
Post a Comment