c# - How do I stop Scrollviewer from expanding to infinite height? -


i have grid, 3 rows. row 2 has variable height, window resizable, , have datagrid on row 3, held within scrollviewer, within tabcontrol.

when there many items in scrollviewer, scrollviewer expands until reaches "max height" available it, max height infinity... keeps growing , growing. want do, stop expanding if mean pushing parent grid out of bounds, , instead use scroll functionality... here general layout of it:

<tabcontrol grid.column="0" grid.row="2" grid.columnspan="3">     <tabitem header="weapons">         <scrollviewer>             <datagrid>                 ...             </datagrid>          </scrollviewer>      </tabitem> </tabcontrol> 

that held within grid has 3 rows , 3 columns. there content in rows 0 , 1 didnt put here, , took out unnecessary info datagrid etc...

example of see:

this turns out like

as requested, whole xaml. not short, why thought simplified version above better. xaml - large fit in post

ok, there. looking @ both datagrids held in different tabs of tabcontrol on row 2 of grid.

condensed "full" xaml:

<grid> <grid.columndefinitions>     <columndefinition />     <columndefinition />     <columndefinition /> </grid.columndefinitions> <grid.rowdefinitions>     <rowdefinition />     <rowdefinition />     <rowdefinition /> </grid.rowdefinitions>  <grid grid.row="0" grid.column="1">      <image source="{staticresource emptyslot}" margin="0" width="34"/>     <image source="{binding auraslot, fallbackvalue={staticresource auraslot}}" margin="0" width="34"/> </grid>  <popup allowstransparency="true" placement="relative" placementtarget="{binding elementname=mainwindowname}" isopen="{binding weapontooltipopen}" horizontaloffset="{binding weaponoffsetx}" verticaloffset="{binding weaponoffsety}" popupanimation="fade" opacitymask="white" >     ... </popup>  <grid grid.column="0" grid.row="1" grid.columnspan="3">      <expander orizontalalignment="center">         <expander.header>             <textblock text="equipment slots" horizontalalignment="center" />         </expander.header>          <grid grid.row="0" grid.column="1">             ...         </grid>      </expander> </grid>  <tabcontrol grid.column="0" grid.row="2" grid.columnspan="3">     <tabitem header="weapons">         <grid>             <scrollviewer cancontentscroll="true" >                 <datagrid grid.column="0" grid.row="2" grid.columnspan="3" itemssource="{binding groupedweapons}" autogeneratecolumns="false" isreadonly="true" alternatingrowbackground="gainsboro" alternationcount="2" rowheaderwidth="0">                     <datagrid.groupstyle>                         <groupstyle>                             ...                         </groupstyle>                     </datagrid.groupstyle>                      <datagrid.columns>                         ...                     </datagrid.columns>                      <datagrid.rowdetailstemplate>                         <datatemplate>                             <stackpanel>                                 ...                             </stackpanel>                         </datatemplate>                     </datagrid.rowdetailstemplate>                  </datagrid>             </scrollviewer>         </grid>     </tabitem>   </tabcontrol> </grid> 

ok, found problem.

i don't knwo reason why problem, because doesn't make sense me, way in code had things wrapped in stackpanel. 2 things stacked there textblock, , grid, grid containing ton of other things, including code posted along question. taking out stackpanel made work correctly, have permanently replaced stackpanel grid, using 2 differnet rows. :)


Comments