Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
390
Template Bindings with UnboundFields in XamDataGrid
posted

Hello.  I have an XamDataGrid of objects; each object has two properties I want to edit within the grid. I'm creating my FieldLayout programatically, to allow a varying number of columns. When I define my layout, I can set the binding for each Field so the PropertyPath points to a particular column in my ViewModel ((i.e. Path="Columns[0]", Path="Columns[1]", etc.) This works fine:

http://imgur.com/rJLCKiR

I want to apply a template to the CellValuePresenter to let me edit each field, with one textbox bound to each of the two fields:

http://imgur.com/9IEq1Du

As you can see, the template bindings aren't correct. Right now, the template has bindings to one of the columns (Path="DataItem.Columns[0]"), since I can't figure out a simple way to get the index for each column into the template. What I really want is for the CellValuePresenter to get the correct bound object, defined in my FieldLayout, but bind each textbox to the appropiate property.

Any help would be vastly appreciated.

src.zip