.net - Binding Grid column width -



facing following problem in design of xaml.

i need arrive @ end arrange data grid custom datatemplate. create top grid contains 2 header lables of data items. below grid build stackpanel itemscontrol includes datatemplate displays data. ok, when run application header lables , data items below grid. problem labels , content of items not aligned correctly. thought binding width of header lable columns actualwidth of itemtemplate, unfortunately not work.

is there clean way achive this?
in advance ...

there easy way using sharedsizegroup in grid columns , assinging grid.issharedsizescope="true" parent.

e.g.

    <stackpanel grid.issharedsizescope="true">         <grid name="headers">             <grid.columndefinitions>                 <columndefinition sharedsizegroup="a"/>                 <columndefinition sharedsizegroup="b"/>             </grid.columndefinitions>             <textblock grid.column="0" text="name"/>             <textblock grid.column="1" text="occupation"/>         </grid>         <itemscontrol name="items" itemssource="{binding data}">             <itemscontrol.itemtemplate>                 <datatemplate>                     <grid>                         <grid.columndefinitions>                             <columndefinition sharedsizegroup="a"/>                             <columndefinition sharedsizegroup="b"/>                         </grid.columndefinitions>                         <textblock grid.column="0" text="{binding name}"/>                         <textblock grid.column="1" text="{binding occupation}"/>                     </grid>                 </datatemplate>             </itemscontrol.itemtemplate>         </itemscontrol>     </stackpanel> 

all items have same widths in columns, thing might need line manually headers section above items, depending on margin settings , like.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -