Hi Telerik
In the following xaml I have set up a RadGridView with two columns:
This xaml was placed in a window with the following code behind:
Now if you run this code you will notice that the two DataGrid columns behave differently when you are updating them. As I understand, when ActionOnLostFocus is set to "CommitEdit" the cell being edited should save its new value when it looses focus. The cells in the first column behave in this fashion, however those in the second column do not - Each reverts to its old value whenever it looses focus.
Why is this? How do I change the behavior of the cells in the second column so that each cell saves its new value when focus is transfered elsewhere?
Cheers
Bob
In the following xaml I have set up a RadGridView with two columns:
<t:RadGridView ItemsSource="{Binding Persons}" ActionOnLostFocus="CommitEdit" AutoGenerateColumns="False" > |
<t:RadGridView.Columns> |
<!-- Auto column --> |
<t:GridViewDataColumn DataMemberBinding="{Binding Path=ID}" /> |
<!-- Manual column --> |
<t:GridViewDataColumn DataMemberBinding="{Binding Name}"> |
<t:GridViewDataColumn.CellTemplate> |
<DataTemplate> |
<TextBlock Text="{Binding Name}" /> |
</DataTemplate> |
</t:GridViewDataColumn.CellTemplate> |
<t:GridViewDataColumn.CellEditTemplate> |
<DataTemplate> |
<TextBox Text="{Binding Name,Mode=TwoWay}" /> |
</DataTemplate> |
</t:GridViewDataColumn.CellEditTemplate> |
</t:GridViewDataColumn> |
</t:RadGridView.Columns> |
</t:RadGridView> |
This xaml was placed in a window with the following code behind:
using System.Collections.ObjectModel; |
using System.Windows; |
namespace WpfApplication2 |
{ |
/// <summary> |
/// Interaction logic for MainWindow.xaml |
/// </summary> |
public partial class MainWindow : Window |
{ |
public MainWindow() { |
InitializeComponent(); |
this.DataContext = this; |
} |
public ObservableCollection<Employee> Persons |
{ get { return EmployeeService.GetEmployees(); } } |
} |
public class Employee { |
public int ID { get; set; } |
public string Name { get; set; } |
} |
public class EmployeeService { |
public static ObservableCollection<Employee> GetEmployees() |
{ |
ObservableCollection<Employee> employees = new ObservableCollection<Employee>(); |
Employee employee = new Employee(); |
employee.Name = "Maria"; |
employee.ID = 24890; |
employees.Add(employee); |
employee = new Employee(); |
employee.Name = "Ana"; |
employee.ID = 23890; |
employees.Add(employee); |
employee = new Employee(); |
employee.Name = "Antonio"; |
employee.ID = 24890; |
employees.Add(employee); |
employee = new Employee(); |
return employees; |
} |
} |
} |
Now if you run this code you will notice that the two DataGrid columns behave differently when you are updating them. As I understand, when ActionOnLostFocus is set to "CommitEdit" the cell being edited should save its new value when it looses focus. The cells in the first column behave in this fashion, however those in the second column do not - Each reverts to its old value whenever it looses focus.
Why is this? How do I change the behavior of the cells in the second column so that each cell saves its new value when focus is transfered elsewhere?
Cheers
Bob