Hi telerk,
I have a table Customers which has 80000 records and my project use a grid to show them(not use Datapager). It can be showed correctly, but it load all data into memory and takes about 150 MB! I heard that RadGridView support data virtualization if its container like grid which have a fixed height. I make a sample project to verify this, but it still loaded all data and take amount memory.
How I can do this? Because I can not open the UIVirtulization sample on your WPF samples, Could you send me a sample project for this? Thanks very much
this is MainWindow code:
this is MyViewModel code:
I have a table Customers which has 80000 records and my project use a grid to show them(not use Datapager). It can be showed correctly, but it load all data into memory and takes about 150 MB! I heard that RadGridView support data virtualization if its container like grid which have a fixed height. I make a sample project to verify this, but it still loaded all data and take amount memory.
How I can do this? Because I can not open the UIVirtulization sample on your WPF samples, Could you send me a sample project for this? Thanks very much
this is MainWindow code:
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"500"
/>
<
RowDefinition
Height
=
"50"
/>
</
Grid.RowDefinitions
>
<
telerik:RadGridView
ItemsSource
=
"{Binding MyCollection}"
AutoGenerateColumns
=
"False"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
Header
=
"CustommerNumber"
DataMemberBinding
=
"{Binding CustomerNumber}"
IsGroupable
=
"False"
IsFilterable
=
"False"
/>
<
telerik:GridViewDataColumn
Header
=
"CompanyName"
DataMemberBinding
=
"{Binding CompanyName}"
IsSortable
=
"False"
/>
<
telerik:GridViewDataColumn
Header
=
"Address"
DataMemberBinding
=
"{Binding Address}"
/>
<
telerik:GridViewDataColumn
Header
=
"PoBox"
DataMemberBinding
=
"{Binding POBox}"
/>
<
telerik:GridViewDataColumn
Header
=
"PostalCode"
DataMemberBinding
=
"{Binding PostalCode}"
/>
<
telerik:GridViewDataColumn
Header
=
"ContactName"
DataMemberBinding
=
"{Binding ContactName}"
/>
<
telerik:GridViewDataColumn
Header
=
"Phone"
DataMemberBinding
=
"{Binding Phone}"
/>
<
telerik:GridViewDataColumn
Header
=
"Fax"
DataMemberBinding
=
"{Binding Fax}"
/>
<
telerik:GridViewDataColumn
Header
=
"Country"
DataMemberBinding
=
"{Binding Country}"
/>
<
telerik:GridViewDataColumn
Header
=
"Mobile"
DataMemberBinding
=
"{Binding Mobile}"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
<
ScrollViewer
x:Name
=
"LogScrollViewer"
VerticalAlignment
=
"Stretch"
Grid.Row
=
"1"
>
<!--<Button Click="Button_Click" Content="Load"/>-->
<
TextBox
x:Name
=
"tbMemory"
Width
=
"200"
Height
=
"30"
></
TextBox
>
<!--<TextBlock x:Name="Log" TextWrapping="Wrap" FontSize="10" />-->
</
ScrollViewer
>
</
Grid
>
public
MainWindow()
{
//MessageBox.Show("loading main window");
InitializeComponent();
DispatcherTimer timer =
new
DispatcherTimer();
timer.Interval =
new
TimeSpan(0, 0, 1);
timer.Tick += timer_Tick;
timer.Start();
//MessageBox.Show("2");
this
.DataContext =
new
MyViewModel();
}
this is MyViewModel code:
class
MyViewModel : INotifyPropertyChanged
{
#region INotifyPropertyChanged Members
public
event
PropertyChangedEventHandler PropertyChanged;
protected
void
OnPropertyChanged(
string
propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if
(handler !=
null
)
{
handler(
this
,
new
PropertyChangedEventArgs(propertyName));
}
}
#endregion
private
RXOfficeEntities context =
null
;
private
ObservableCollection<Customer> _MyCollection =
null
;
public
ObservableCollection<Customer> MyCollection
{
get
{
return
_MyCollection; }
set
{ _MyCollection = value; OnPropertyChanged(
"MyCollection"
); }
}
public
MyViewModel()
{
context =
new
RXOfficeEntities();
MyCollection =
new
ObservableCollection<Customer>(context.Customers);
}