Hi,
I am using the RadGridView in an MVVM project. The ViewModel has a property ObservableCollection<T> to which the ItemSource property is bound. When a I place a break point in the ViewModel property get, then it is accessed twice. Am I doing something wrong? The XAML is below. Also, what is the best practice when loading data using a pager and ensuring only page size is loaded from the database and not all records (e.g. Take(20));
Regards
Jaco
 
 
                                I am using the RadGridView in an MVVM project. The ViewModel has a property ObservableCollection<T> to which the ItemSource property is bound. When a I place a break point in the ViewModel property get, then it is accessed twice. Am I doing something wrong? The XAML is below. Also, what is the best practice when loading data using a pager and ensuring only page size is loaded from the database and not all records (e.g. Take(20));
Regards
Jaco
<Window x:Class="DBAppBestPractice.MainWindow"                xmlns:Examples="clr-namespace:DBAppBestPractice"                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"                xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"                x:Name="root"                 DataContext="{Binding Main, Source={StaticResource Locator}}"                >    <Window.Resources>        <ResourceDictionary>            <ResourceDictionary.MergedDictionaries>                <ResourceDictionary Source="Skins/MainSkin.xaml" />            </ResourceDictionary.MergedDictionaries>        </ResourceDictionary>    </Window.Resources>         <Grid>        <Grid.RowDefinitions>            <RowDefinition Height="Auto" />            <RowDefinition />        </Grid.RowDefinitions>        <Border  Grid.RowSpan="2" />        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,5,0,0">            <telerik:RadButton Width="150" Content="Delete selected rows" Margin="0,0,5,0"                                 Command="telerikGrid:RadGridViewCommands.Delete" CommandTarget="{Binding ElementName=RadGridView1}"  />            <telerik:RadButton Width="150" Content="Add new row" Margin="0,0,5,0"                                 Command="telerikGrid:RadGridViewCommands.BeginInsert" CommandTarget="{Binding ElementName=RadGridView1}"  />            <telerik:RadButton Width="150" Content="Save insert/edit" Margin="0,0,5,0"                                 Command="telerikGrid:RadGridViewCommands.CommitEdit" CommandTarget="{Binding ElementName=RadGridView1}"  />            <telerik:RadButton Width="150" Content="Cancel insert/edit"                                 Command="telerikGrid:RadGridViewCommands.CancelRowEdit" CommandTarget="{Binding ElementName=RadGridView1}"  />        </StackPanel>        <telerik:RadGridView x:Name="RadGridView1"                                                 ItemsSource="{Binding LoadedSuppliers}"                                                 SelectionMode="Extended"                                                 AutoGenerateColumns="False"                                                 Margin="0,5,0,0"                                                 Grid.Row="1"                                                 ActionOnLostFocus="None" RowEditEnded="RadGridView1_RowEditEnded" Deleted="RadGridView1_Deleted">            <telerik:RadGridView.Columns>                <telerik:GridViewColumn>                    <telerik:GridViewColumn.CellTemplate>                        <DataTemplate>                            <telerik:RadButton Content="Delete" Command="telerikGrid:RadGridViewCommands.Delete" CommandParameter="{Binding}" />                        </DataTemplate>                    </telerik:GridViewColumn.CellTemplate>                </telerik:GridViewColumn>                <telerik:GridViewDataColumn DataMemberBinding="{Binding Id}" Header="Id" IsReadOnly="True" />                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}" Header="Name" />                <telerik:GridViewDataColumn DataMemberBinding="{Binding Description}" Header="Description" />            </telerik:RadGridView.Columns>        </telerik:RadGridView>    </Grid></Window>