c# - How to control the height of WPF Application window based on the contents of dynamic Grid -


i have created wpf application generate tiles in second row of grid. i'm trying achieve keep rendering tiles in second row without showing vertical scroll bar, until unless height of wpf application crosses resolution of user screen.

<window x:class="abc.mainwindow"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     title="abc installation" minwidth="620" sizetocontent="widthandheight" allowstransparency="true" windowstyle="none" loaded="mainwindow_loaded" minheight="600" >     <grid>         <grid.rowdefinitions>             <rowdefinition height="60" />             <rowdefinition height="56" />             <rowdefinition height="auto" scrollviewer.isdeferredscrollingenabled="true" />                         <rowdefinition height="94"/>         </grid.rowdefinitions> </grid>      <scrollviewer name="productsouterscroll" grid.row="2" horizontalscrollbarvisibility="hidden" scrollviewer.verticalscrollbarvisibility="auto" grid.rowspan="1" >         <stackpanel x:name="formstackpanel">         </stackpanel>     </scrollviewer> 

this code renders tiles exceeding user screen window height without vertical scroll bar.

any idea how this? appreciated.

if want content scroll, remove height rowdefinition of row adding content to, , put content inside scrollviewer.

your window might sizing correctly vertical resolution of screen, if it's displayed in center of screen, exceed height. can set startup location top of screen with:

windowstartuplocation="manual" top="0" 

if window height high, might want set maximum height window.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -