c# - Distribute columns evenly in WPF DataGrid -


i have window set sizetocontent="widthandheight" , in window there row of controls want define width of window. underneath controls datagrid 3 columns.

however can't seem evenly distribute 3 columns same size , use space available. there way in c#.net?

you can via databinding. example:

<window x:class="wpfapplication2.mainwindow"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" sizetocontent="widthandheight">   <stackpanel orientation="vertical">     <stackpanel orientation="horizontal" x:name="panel">         <label content="1" width="90"/>         <label content="2" width="90"/>         <label content="3" width="90"/>     </stackpanel>      <datagrid width="{binding actualwidth, elementname=panel}">         <datagrid.columns>             <datagridtextcolumn header="1" width="*"/>             <datagridtextcolumn header="2" width="*"/>         </datagrid.columns>     </datagrid>   </stackpanel> </window> 

Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -