c# - Applying a transform to all child elements in WPF -


i implementing behavior in application resize main content area depending on screen size. (the content area made of icons , other elements user can place/draw)

currently, margin property used position elements using converter converts point thickness.

example:

http://i.imgur.com/tom7zke.png

"scaling" going for, child elements "scaled", position wise, size of container.

how can apply transform (rendertransform or layouttransform) child elements of grid, icon positions scale correct position depending on grid size?

it should noted these icons may removed/added while application running. position of elements needs scaled, not size.

i have done before, , suggest this:

  1. in element class (say, circle), have sort of coordinate representing position, proportionally size of container. so, 0.5 represent middle, 0.33 represent 1 third left, etc.
  2. create imultivalueconverter calculates pixel coordinate based on relative coordinate , container size along given dimension;
  3. declare object in xaml margins (in case of grid container) or canvas.top/left (in case of canvas container) in following way:

xaml:

<circle>     <circle.margin>         <multibinding converter="{staticresource thatconverter}">             <binding elementname="container" path="actualwidth"/>             <binding path="circlecoordinatex"/>             <!-- same height , y coordinate -->         </multibinding>     </circle.margin> </circle> 

instead of more simplistic approach, ideally should make container itemscontrol, create itemstemplate datatype circle, , bind container itemssource observablecollection on viewmodel, example.


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 -