开发者

Trigger silverlight datagrid to resize

开发者 https://www.devze.com 2023-01-25 08:47 出处:网络
I have a situation where I\'m using a datagrid to display two different sets of columns based on the data being displayed.I hide/display the columns based on the data and one type has more columns dis

I have a situation where I'm using a datagrid to display two different sets of columns based on the data being displayed. I hide/display the columns based on the data and one type has more columns displayed. An example of the type of setup I have is:

Type1 columns: Name, DOB, Address, Height, Weight, Occupation, Years Experience.

Type2 columns: Name, DOB, Address, Height, Occupation, Marital Status, Hair Color, Eye Color, Ethnicity.

My dataGrid columns are the union of these two sets.

When I display Type1, I get seven columns of equal width. When I switch to Typ开发者_运维技巧e2, I set Weight and Years Experience to collapsed and set Marital Status, Hair Color, Eye Color, and Ethnicity to visible. The first 3 columns retain their width and the last 6 columns get scrunched down to fit. Does anyone know how to trigger a resize of all the columns?

Edit: I'm using Width="*" for all columns


Call UpdateLayout on the Grid


UpdateLayout gets called on it's own when you change something. I found if I initially display it in it's entirety (all columns) then It diplays properly. You can do this for a split second and the user will never see it.

0

精彩评论

暂无评论...
验证码 换一张
取 消