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