views:

1202

answers:

1

I'm trying to force a grid/expander to reevaluate whether it needs a scrollbar, as it's showing emptiness.

I'm using this layout:

<Grid>
  <toolstrip /> <!-- fixed height row -->
  <Scrollviewer>  <!-- * height -->
    <Grid> <!-- all rows are 'Auto' height -->
      <Expander />
      <Expander> <!-- this one stretches far too high -->
        <WPF Toolkit: DataGrid />
      <Expander>
      <GridSplitter/>
      <Expander />
    <Grid>
  </Scrollviewer>
  <stackpanel />   <!-- fixed height row -->
<Grid>

The DataGrid (WPF Toolkit) is bound to a property when the Window is initialized. Through some investigating, I've realized that when the window is initialized, the columns in the GridView start at about 10 pixels wide, then the content is added, then they're resized based on the sizes in the XAML (All using star widths - eg: 2*). This causes the grid to resize to about 6 times the height it needs to be as the window is showing, then it doesn't spring back and the only way to see what's at the bottom of the window is to either scroll or move the GridSplitter back up to where it should be and resize the Window. I haven't set the VerticalAlignment properties on anything.

So far I've tried all of the following called InvalidateArrange(), InvalidateVisual();, InvalidateMeasure() and UpdateLayout() on the problem expander and InvalidateArrange(), InvalidateScrollInfo(), InvalidateVisual() and UpdateLayout() on the Grid above it but it won't shrink back.

Is there any way I can force it to short of forcing the width of the columns in the DataGrid?

A: 

Try setting these properties on the ScrollViewer:

<ScrollViewer CanContentScroll="True"
              VerticalScrollBarVisibility="Auto" 
              HorizontalScrollBarVisibility="Auto">
    ... content ...
</ScrollViewer>

If that doesn't work, can you provide a more exact representation of your XAML. Also, taking a look at the ScrollViewer in depth may help.

rmoore