c# - Bind Grid width to ParentGrid.Width - ParentGridBorder.BorderThickness -
i started wpf, please bear me on simple mistakes.
as title states, want bind grid's width innerwidth of parentgrid. code example (very stripped down):
<grid name="parentgrid" width="300"> <border name="parentgridborder thickness="2" width="{binding width, elementname=parentgrid}" /> <grid name="childgrid" width="{**? parentwidth - parentborderthickness ?**}"> .... </grid> </grid>
i'm using visual studio 2012, wpf, , c# code-behind (i assume pretty standard setup). appreciated.
addendum: poor , misguided approach due newbishness towards wpf. selected answer pointed out sizing issues trying create workarounds for.
i recommend ignore grid.border idea , instead add margin second grid. unless require border other reason, way go.
<grid name="parentgrid" width="300"> <grid name="childgrid" margin="10"> .... </grid> </grid>
objects inside grids naturally fit parent's size unless explicitly stated otherwise.
note child grid maintains size
Comments
Post a Comment