c# - ItemContainer style with nested ItemControls won't bind correctly -


a summary of i'm trying do:

  1. i have list of shapes
  2. all shapes have list of blocks
  3. 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

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -