In my xamdatagrid, I have a context menu and on clicking on the menu "OnAdd", I am trying to enable AddNew row functionality by binding the a property to
AllowAddNew. It has no effect. Apart from that, I tried using AllowAddNew directly on grid, apparently it has no effect either. How can I enable AllowAddNew ?
Hello Rajib,
I am glad you were able to come up with a solution.
Please let me know if you have any other questions.
Sincerely,Valerie Developer Support Supervisor - XAMLInfragisticswww.infragistics.com/support
Thanks for the reply. I came up with a different solution using DependencyProperty
public static readonly DependencyProperty IsAllowAddNewProperty =
DependencyProperty.Register(
"IsAllowAddNew", typeof(bool), typeof(BlotterGrid),
new FrameworkPropertyMetadata(false, new PropertyChangedCallback(OnIsAllowAddNewChanged), null));
public bool IsAllowAddNew
{
get { return (bool)GetValue(IsAllowAddNewProperty); }
set { SetValue(IsAllowAddNewProperty, value); }
}
private static void OnIsAllowAddNewChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
var control = (BlotterGrid)obj;
var e = new RoutedPropertyChangedEventArgs<bool>(
(bool)args.OldValue, (bool)args.NewValue, null);
control.OnIsAllowAddNewChanged(e);
protected virtual void OnIsAllowAddNewChanged(RoutedPropertyChangedEventArgs<bool> args)
CustomBlotterGrid.FieldSettings.AllowEdit = args.NewValue;
CustomBlotterGrid.FieldLayoutSettings.AllowAddNew = args.NewValue;
When binding to a collection of IProduct the grid would be able to read the existing, previously created items it just can’t create new ones since there is way to create an instance of an interface. For example, there is no such thing as IProduct p = new IProduct();
As far as an alternate binding for AllowAddNew in 14.1, since the FieldLayoutSettings are not in the visual tree you would need to use an alternate approach to binding. The following posts discuss methods of accomplishing this:
http://www.codeproject.com/Articles/18678/Attaching-a-Virtual-Branch-to-the-Logical-Tree-in
http://www.codeproject.com/Articles/27432/Artificial-Inheritance-Contexts-in-WPF
Please let me know if you have any questions.
Sincerely,
Valerie
Developer Support Supervisor - XAML
Infragistics
www.infragistics.com/support
Valerie, in your first reply you mentioned about FieldBinding markup extension. Is there any similar option available with v 14.1 to bind gthe property AllowAddNew via MVVM property ?
But I am able to bind the grid with ObservableCollection<IProduct>. Its only while adding, I am having the issue.