wpf - Bind Grid.Row / Grid.Column inside a DataTemplate -
hope not dupe.
i able next in xaml:
<datatemplate datatype="{x:type testapp:buttonvm}"> <button grid.column="{binding gridcolumn}" grid.row="{binding gridrow}" content="{binding path=info}" /> </datatemplate>
the content binding works fine grid.column , grid.row don't exist in produced object. not when set them value without binding (like in grid.column="1"). i've snooped application , saw within grid nobody ever sets grid.column , grid.row.
any ideas?
solved myself help blogs.
as far understand can't attached property binding inside.
the next solves problem in instant (itemcontainerstyle!):
<datatemplate datatype="{x:type testapp:gridvm}"> <itemscontrol itemssource="{binding path=children}"> <itemscontrol.itemcontainerstyle> <style> <setter property="grid.row" value="{binding gridrow}" /> <setter property="grid.column" value="{binding gridcolumn}" /> </style> </itemscontrol.itemcontainerstyle> <itemscontrol.itemspanel> <itemspaneltemplate> <grid showgridlines="true" style="{binding path=style}"> <grid.rowdefinitions> <rowdefinition height=".5*" /> <rowdefinition height=".5*" /> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width=".5*" /> <columndefinition width=".5*" /> </grid.columndefinitions> </grid> </itemspaneltemplate> </itemscontrol.itemspanel> </itemscontrol> </datatemplate>
wpf data-binding mvvm attached-properties
No comments:
Post a Comment