Hallo,
I got problems with the GridView performance.
I have a simple WPF Application with one GridView and one refresh button. The GridView has 4 columns and 100 rows. The ItemsSource of the GridView is an Observable Collection of the type RowViewModel. RowViewModel has 4 properties (1 DateTime and 3 strings). When I push the refresh button, the ItemsSource is cleared and filled again with different objects. On my machine thit takes about 800 to 1000 ms. Here is the XAML code:
And here is the code behind:
Nothing special here, why does it take about 1 second to refresh the ItemsSource collection?
Thank you for the help,
Eugen
I got problems with the GridView performance.
I have a simple WPF Application with one GridView and one refresh button. The GridView has 4 columns and 100 rows. The ItemsSource of the GridView is an Observable Collection of the type RowViewModel. RowViewModel has 4 properties (1 DateTime and 3 strings). When I push the refresh button, the ItemsSource is cleared and filled again with different objects. On my machine thit takes about 800 to 1000 ms. Here is the XAML code:
<
Grid
>
<
telerik:RadGridView
HorizontalAlignment
=
"Left"
Name
=
"radGridView1"
VerticalAlignment
=
"Top"
Height
=
"561"
Width
=
"546"
>
</
telerik:RadGridView
>
<
telerik:RadButton
Content
=
"Refresh"
Height
=
"23"
HorizontalAlignment
=
"Left"
Margin
=
"646,152,0,0"
Name
=
"radButton1"
VerticalAlignment
=
"Top"
Width
=
"75"
Click
=
"radButton1_Click"
/>
</
Grid
>
And here is the code behind:
private
const
int
RowCount = 100;
private
int
_counter = 0;
private
readonly
string
[] _codes =
new
[] {
"Code Blue"
,
"Code Orange"
,
"Code Yellow"
,
"Code Cyan"
};
public
MainWindow()
{
InitializeComponent();
CreateRowViewModels();
}
public
ObservableCollection<RowViewModel> Rows {
get
;
set
; }
private
void
CreateRowViewModels()
{
if
(Rows ==
null
)
{
Rows =
new
ObservableCollection<RowViewModel>();
radGridView1.ItemsSource = Rows;
}
DateTime d;
string
name;
if
(_counter % 2 == 0)
{
d =
new
DateTime(2012, 1, 1);
name =
"Mr. Black"
;
}
else
{
d =
new
DateTime(2012, 6, 1);
name =
"Mr. White"
;
}
Rows.Clear();
for
(var i = 0; i < RowCount; i++)
{
var row =
new
RowViewModel
{
Name = name +
" "
+ (i + 1),
Date = d,
Code = _codes[i % 4],
Error =
""
};
Rows.Add(row);
}
_counter++;
}
private
void
radButton1_Click(
object
sender, RoutedEventArgs e)
{
CreateRowViewModels();
}
Nothing special here, why does it take about 1 second to refresh the ItemsSource collection?
Thank you for the help,
Eugen