Hi,
First thing I can see : In you XAML, the "xcdg:Column" should be included in a "xcdg:DataGridControl.Columns" tag.
After modifying slightly your sample, I have 2 calls to "UpdateSource" and 1 call to "UpdateTarget" wheather there is an error or not.
Before going further in the code, can you check my sample does what you want or if I am missing something through my sample that could explain the 13 calls.
Thanks.
First thing I can see : In you XAML, the "xcdg:Column" should be included in a "xcdg:DataGridControl.Columns" tag.
After modifying slightly your sample, I have 2 calls to "UpdateSource" and 1 call to "UpdateTarget" wheather there is an error or not.
Before going further in the code, can you check my sample does what you want or if I am missing something through my sample that could explain the 13 calls.
Thanks.
<xcdg:DataGridControl x:Name="_dataGrid"
AutoCreateColumns="False"
IsDeleteCommandEnabled="False"
IsRefreshCommandEnabled="False"
ItemScrollingBehavior="Immediate"
ItemsSource="{Binding Path=OrderDetails}">
<xcdg:DataGridControl.Columns>
<xcdg:Column FieldName="Quantity"
CellEditorDisplayConditions="CellIsCurrent"
CellHorizontalContentAlignment="Right"
Title="Quantity">
<xcdg:Column.CellContentTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=., StringFormat={}{0:N0}, ValidatesOnDataErrors=True}" />
</DataTemplate>
</xcdg:Column.CellContentTemplate>
<xcdg:Column.CellErrorStyle>
<Style TargetType="{x:Type xcdg:Cell}">
<Setter Property="BorderBrush"
Value="Red" />
<Setter Property="BorderThickness"
Value="1" />
</Style>
</xcdg:Column.CellErrorStyle>
<xcdg:Column.CellEditor>
<xcdg:CellEditor>
<xcdg:CellEditor.EditTemplate>
<DataTemplate>
<toolkit:IntegerUpDown Value="{xcdg:CellEditorBinding}"
Minimum="0" />
</DataTemplate>
</xcdg:CellEditor.EditTemplate>
</xcdg:CellEditor>
</xcdg:Column.CellEditor>
</xcdg:Column>
</xcdg:DataGridControl.Columns>
</xcdg:DataGridControl>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
_dataGrid.DataContext = this;
this.OrderDetails = new ObservableCollection<OrderDetail>()
{
new OrderDetail() { Name = "Orange", Quantity = 12},
new OrderDetail() { Name = "Apple", Quantity = 2},
new OrderDetail() { Name = "Tomato", Quantity = 33},
new OrderDetail() { Name = "Strawberry", Quantity = 10},
new OrderDetail() { Name = "Peas", Quantity = 15}
};
}
public ObservableCollection<OrderDetail> OrderDetails
{
get;
set;
}
}
public class OrderDetail : IDataErrorInfo, INotifyPropertyChanged
{
public string Name
{
get;
set;
}
public int Quantity
{
get
{
return quantity;
}
set
{
quantity = value;
this.NotifyPropertyChanged( "Quantity" );
}
}
private int quantity;
public event PropertyChangedEventHandler PropertyChanged;
protected void NotifyPropertyChanged( string propertyName )
{
if( this.PropertyChanged != null )
{
this.PropertyChanged( this, new PropertyChangedEventArgs( propertyName ) );
}
}
public string Error
{
get
{
return string.Empty;
}
}
public string this[ string columnName ]
{
get
{
string result = null;
switch( columnName )
{
case "Quantity":
{
if( this.Quantity <= 5 )
{
result = "Value must be greater than 5";
}
break;
}
default:
{
break;
}
}
return result;
}
}
}