title: Sizing DataGrid to fit to its content when space available in WPF
body: <p>I am new to WPF. I have got a <code>DataGrid</code> which is placed inside a <code>Grid</code> with row height set to <code>"*"</code> . I want this <code>DataGrid</code> height to fit to its content if the window height is not less than the total content height of the <code>DataGrid</code>, else show a vertical <code>ScrollViewer</code>. I have tried to surround it with a <code>StackPanel</code> which does the first job, i.e. resizing of the <code>DataGrid</code> height to fit to its content, but at a cost of not showing the vertical <code>ScrollViewer</code> which was appearing when the <code>DataGrid</code> was a direct child of the <code>Grid</code>. How I can achieve the required behaviour?</p>