I have several components that take seconds to load.
My problem is that datagrid components have provided the page before computing its column width and the user can see the rendering on the screen.
I made a very simple example: DataGrid 3 columns, the first column has a width = "*"
and another column has a fixed width is. Fixed width columns are sung properly from the beginning, but the star column has been presented with a width of 20.
After one second < Strong> DataGrid calculates the correct width of the star column and provides the grid correctly:
My example is XAML:
& lt; ScrollViewer & gt; & Lt; Control: DataGrid name = "main table" auto generated column = "incorrect" & gt; & Lt; Control: DataGrid.Columns & gt; & Lt; Control: Data Grid Template Column Header = "Colonel 0" width = "*" & gt; & Lt; Control: DataGridTemplateColumn.CellTemplate & gt; & Lt; DataTemplate & gt; & Lt; Text block text = "{binding call 0}" /> & Lt; / DataTemplate & gt; & Lt; / Control: DataGridTemplateColumn.CellTemplate & gt; & Lt; / Control: DataGridTemplateColumn & gt; & Lt; Control: DataGridTextColumn Header = "Colonel 1" binding = "{binding call1}" width = "150" /> & Lt; Control: Data Grid Text Clulam Header = "Call 2" Binding = "{Binding Call 2}" width = "150" /> & Lt; / Control: DataGrid.Columns & gt; & Lt; / Control: data grid & gt;
and the rear code:
public manwindows () {InitializeComponent (); Var rows = new list & lt; Rowo & gt; (); For (Int i = 0; I & lt; 5000; i ++) {rows.ed (new rows {call 0 = "call 0," + i, call1 = "call1," + i, call2 = " Cola2, "+ i, call3 =" col 3, "+ i, call 4 =" tomorrow 4, "+ i,}); } MainTable.ItemsSource = Rows; }
As a note: I can not switch to WpfToolkit (latest release, 2010) and .NET 3.5 and I do not have WPF4 components.
Any idea how to fix the loading problem?
Move the above argument to the list above InitializeComponent ()
and simply < Code> ItemsSource set later:
public main window () {var rows = new list & lt; RowObj & gt; (); For (Int i = 0; I & lt; 5000; i ++) {rows.ed (new rows {call 0 = "call 0," + i, call1 = "call1," + i, call2 = " Cola2, "+ i, call3 =" col 3, "+ i, call 4 =" tomorrow 4, "+ i,}); } InitializeComponent (); MainTable.ItemsSource = Rows; }
Comments
Post a Comment