xaml - Silverlight: Make all descendants of an element have a margin? -


is there way in silverlight 4 dictate elements within stackpanel must have margin, instead of specifying margin="10,0" on each one?

i'm afraid it's not possible declaratively in xaml stackpanel directly. it's conceptual philosophy in silverlight/wpf panel should not modify properties of children. implement own panel anyway, or use itemscontrol that:

<itemscontrol>     <itemscontrol.itemtemplate>         <datatemplate>             <contentpresenter margin="10,0" content="{binding content}" />         </datatemplate>     </itemscontrol.itemtemplate>      [...]  </itemscontrol> 

an itemscontrol uses stackpanel default, can use itemspanel property define panel itemspaneltemplate if wish so.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -