C#/WPF: Align top border of a data grid to the top border of an image varying in size -


i developing wpf application using c#. grid divides application 2 columns. in left column placed datagrid , in right column have image. image has option stretch="uniform" set , therefore adopts height optimally fill grid column keeping aspect ratio, if size of main window changed. image has vertically centered within column.

as result above setup leads white/blank border on top of image. align top of datagrid in left column top of automatically scaled image in right column. therefore have somehow bind data of image distance top border data grid distance top border.

you need set verticalalignment="top" on elements in grid panel. example below:

 <grid>     <grid verticalalignment="center">         <grid.columndefinitions>             <columndefinition width="auto"/>             <columndefinition width="*"/>         </grid.columndefinitions>          <image grid.column="0"            verticalalignment="top"            maxwidth="100"            source="https://www.google.com/images/srpr/logo11w.png"></image>          <datagrid grid.column="1"                margin="10 0 0 0"            verticalalignment="top">             <datagrid.columns>                 <datagridtextcolumn header="column1"/>                 <datagridtextcolumn header="column2"/>                 <datagridtextcolumn header="column3"/>                 <datagridtextcolumn header="column4"/>             </datagrid.columns>         </datagrid>     </grid> </grid> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -