c# - Two Way Binding Path=. Will Not Save -
public datacontext { public observerablecollection<int> integers; } <datagrid itemssource={binding integers, mode=twoway}> <datagrid.columns> <datagridtextcolumn binding="{binding path=., updatesourcetrigger=propertychanged, mode=twoway}"/> </datagrid.columns> </datagrid>
shows numbers fine. but, if modify something, values never save. can enter 999999 , collection never update index corresponding row.
if made silly wrapper class called integermodel , give integer called "value" , set, change binding path=. binding path=value, works fine.
this site mentions in answer, doesn't know why. i'd know why myself. if inotifypropertychanged event issue, why work normal getter , setter wrapper?
i'm basing on know .net framework's internals. educated guess.
the "silly wrapper class" mention "boxes" integers, value types, object types. permits add implementation of inotifypropertychanged
, necessary because binding not observablecollection
, instead 1 binding each of elements in observablecollection
. gives binding system hooks needs modify integers when changes trigger source update.
it slower operations pure value types, but, if you're operating @ user interface speeds, shouldn't discernible problem.
Comments
Post a Comment