c# - How to specify the width of the datagrid column to occupy the remaining space? -
i developing silverlight 4 application. have following datagrid
<data:datagrid x:name="studentdatagrid" autogeneratecolumns="false" height="200" horizontalalignment="left" margin="176,96,0,0" verticalalignment="top" width="200"> <data:datagrid.columns> <data:datagridtextcolumn header="first name" binding="{binding firstname}"></data:datagridtextcolumn> <data:datagridtextcolumn width="*" header="last name" binding="{binding lastname}" ></data:datagridtextcolumn> </data:datagrid.columns> </data:datagrid>
i binding following list datagrid
public list<student> getstudents() { list<student> studentlist = new list<student>(); student s1 = new student(); s1.firstname = "anil"; s1.lastname = "jadhav"; student s2 = new student(); s2.firstname = "shyam"; s2.lastname = "jodh"; studentlist.add(s1); studentlist.add(s2); return studentlist; }
the code works fine. * width occupy remaining space. wen s1.firstname assigned value has long string the code run datagrid not show scrollbar. lastname column goes right side , gets hidden. dont want increase width of datagrd. how solve above problem ? why datagrid not showing scrollbar ? can please provide me code or link through can solve above issue.
this link here describes solution problem. bit sceptical, doesn't work wpf (i don't have silverlight), interested in hearing if works.
otherwise think have set width of last column dynamically, example using trigger.
Comments
Post a Comment