DataBindingComplete Command
The DataBindingComplete
command provides an MVVM-friendly implementation of the DataBindingComplete
event. This event is useful when some logic needs to be executed after the data view is generated. Since the DataGrid provides a multi-threaded implementation of all the in-memory data operations like grouping, sorting, and filtering, the DataBindingComplete
event is the safe entry point which grants that all the data-related operations are successfully completed and the data view can be accessed and manipulated.
Execution Parameter
The execution parameter is of type DataBindingCompleteEventArgs
and exposes the following properties:
-
DataView
—Gets theTelerik.UI.Xaml.Controls.Grid.IDataView
implementation that allows for traversing and/or manipulating the already computed dataView
. -
ChangeFlags
—Gets the flags that triggered the re-evaluation of the underlying raw data. The possible flags areDataChangeFlags.Group
,DataChangeFlags.Sort
, andDataChangeFlags.Filter
.
Custom DataBindingComplete Command
The following examples show how to create a class that inherits from the DataGridCommand
and add it to the Commands
collection.
Create a Custom DataBindingComplete Command
public class CustomDataBindingCompleteCommand : DataGridCommand
{
public CustomDataBindingCompleteCommand()
{
this.Id = CommandId.DataBindingComplete;
}
public override bool CanExecute(object parameter)
{
var context = parameter as DataBindingCompleteEventArgs;
// put your custom logic here
return true;
}
public override void Execute(object parameter)
{
var context = parameter as DataBindingCompleteEventArgs;
// put your custom logic here
this.Owner.CommandService.ExecuteDefaultCommand(CommandId.DataBindingComplete, context);
}
}
Add the Custom Command to the Commands Collection
<Grid xmlns:grid="using:Telerik.UI.Xaml.Controls.Grid">
<grid:RadDataGrid Width="600" Height="460" x:Name="grid" Hold>
<grid:RadDataGrid.Commands>
<local:CustomDataBindingCompleteCommand/>
</grid:RadDataGrid.Commands>
</grid:RadDataGrid>
</Grid>