How do you do relative positioning in WPF?

前端 未结 2 441
旧时难觅i
旧时难觅i 2020-12-24 13:18

How can you relatively position elements in WPF? The standard model is to use layout managers for everything, but what if you want to position elements (on a Canvas, for exa

2条回答
  •  甜味超标
    2020-12-24 13:48

    Instead of putting (as in your example) a button directly on the canvas, you could put a stackpanel on the canvas, horizontally aligned, and put the two buttons in there.

    Like so:

    
      
        
      
    
    

    alt text

    I think that it's quite flexible when you use more than 1 layout in a form, and you can create pretty much any configuration you want.

提交回复
热议问题