or
// App.xaml<Application x:Class="SampleAppWithRadGridView.App" StartupUri="MainWindow.xaml" DispatcherUnhandledException="Application_DispatcherUnhandledException" />// App.xaml.cs private void Application_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { e.Handled = true; MessageBox.Show(e.Exception.Message); }// MainWindow.xaml<telerik:RadGridView Name="gridView" IsReadOnly="False" EditTriggers="F2" Width="200"></telerik:RadGridView>// MainWindow.xaml.cspublic partial class MainWindow : Window { IList<Student> studentList = new List<Student>(); public MainWindow() { InitializeComponent(); InitializeStudentList(); LoadGrid(); } void InitializeStudentList() { studentList.Add(new Student { FirstName = "Robert", LastName = "Williams" }); studentList.Add(new Student { FirstName = "Eric", LastName = "James" }); studentList.Add(new Student { FirstName = "Randy", LastName = "Spencer" }); gridView.ItemsSource = studentList; } void LoadGrid() { gridView.CellValidating += HandleCellValidating; } void HandleCellValidating(object sender, GridViewCellValidatingEventArgs e) { if (studentList.Any(s => s.FirstName == e.NewValue.ToString())) { e.Handled = true; throw new Exception(); } } }settings.Roots.Add(this.diagram.ContainerGenerator.ContainerFromItem(this.maintViewModel.Source.Items.OfType<object>().ElementAt(0)) as IShape);this.diagram.Layout(LayoutType.Tree, settings);this.diagram.AutoFit();
