Often collection data is better presented in a tabular view and better edited in a form view. Such UX approach is referred by our clients as “Popup editing in RadGridView”.
With the help of the new RadDataForm and the good old RadGridView a few lines of code are needed to accomplish this.
Image may be NSFW.
Clik here to view.
To have this working we need to :
1. Bind RadGridView to a collection IEditable and INotifyPropertyChange objects.
this.RadGridView1.ItemsSource = Person.GetSampleListOfPersons();2. Bind a RadDataForm to the current item of RadGridView
<telerik:RadDataForm CurrentItem="{Binding CurrentItem,ElementName=RadGridView1}" …
3. Handle the button event to show RadDataForm when needed.
private void Edit_Click(object sender, RoutedEventArgs e)
{
this.RadGridView1.CurrentItem = ((Button)sender).DataContext;
this.RadDataForm1.Visibility = Visibility.Visible;
this.RadDataForm1.BeginEdit();
}
4.Handle the EditEnded event of RadDataform to hide it when no more needed.
void RadDataForm1_EditEnded(object sender, Telerik.Windows.Controls.Data.DataForm.EditEndedEventArgs e) { this.RadDataForm1.Visibility = Visibility.Collapsed; }
That is all you need to have popup editing in RadGridView .
The full source code and a demo app may be downloaded