Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF DataGrid resize with Window Resize

$
0
0

Hi All,

   We have a use case where a resizable window hosts a DataGrid.  By default with window resize DataGrid also gets resized so that it occupies the window accordingly.

  Now there are few constraints within our application on DataGrid resize which have been listed below.

1. Fix Left: During resize of the Window , DataGrid should be resized such that top left location should not be changed. It is nothing but DataGrid should grow in only one direction towards right horizontally. Vertically it should stick to default behavior.

2. Fix Bottom. During resize of the Window , DataGrid should be resized such that it Stretches horizontally but vertical size and position are fixed relative to bottom-left corner.

I have added SizeChanged event for Window and in that I am manipulating DatGrid width and Height specific to the above two constraints. As per constraint 1(Fix Left),  DataGrid top left coordinates should not be changed during resize. So some how I should fix the top left coordinates and the the same time DataGrid should be resized. I just got stuck here and I could not be able to fix top left coordinates for the DataGrid. Due to this during resize of Window DataGrid is moving to the center of the Window.

I have tried many ways to fix top left coordinates for DataGrid but ended up with no success. Constraint 2 (Fix Bottom) also in the similar lines only difference is I have to make sure that Y part of the coordinate should be unchanged during resize.

 Could any one provide any hint on fixing the coordinates of the Grid during resize please?

Thanks,

Brahmaji.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>