c# - ItemContainer style with nested ItemControls won't bind correctly -
a summary of i'm trying do:
- i have list of shapes
- all shapes have list of blocks
- i want draw blocks in canvas , bind position.
but problem right if draw blocks don't bind position correctly , show @ (0,0).
here how right nested itemscontrol:
<itemscontrol itemssource="{binding path=shapes}"> <itemscontrol.itemspanel> <itemspaneltemplate> <canvas background="aqua" width="250" height="400"/> </itemspaneltemplate> </itemscontrol.itemspanel> <itemscontrol.itemtemplate> <datatemplate> <itemscontrol itemssource="{binding blocks}"> <itemscontrol.itemcontainerstyle> <style targettype="contentpresenter"> <setter property="canvas.left" value="{binding x}"/> <setter property="canvas.top" value="{binding y}"/> </style> </itemscontrol.itemcontainerstyle> <itemscontrol.itemtemplate> <datatemplate> <rectangle width="{binding width}" height="{binding height}" fill="black" /> </datatemplate> </itemscontrol.itemtemplate> </itemscontrol> </datatemplate> </itemscontrol.itemtemplate> </itemscontrol>
so doing wrong or bad nested itemcontrols?
try using rendertransform instead of canvas left , top
<itemscontrol.itemtemplate> <datatemplate> <rectangle width="{binding width}" height="{binding height}" fill="black"> <rectangle.rendertransform> <translatetransform x="{binding x}" y="{binding y}" /> </rectangle.rendertransform> </rectangle> </datatemplate> </itemscontrol.itemtemplate>
Comments
Post a Comment