Hi, I am trying to get the current row object or record in my CurrentCellBeginEdit. Is there a way to do this; specifically when I am in the New Row Addition. I tried to add an attachedproperty to my sfdatagrid as below but it stays null:
public class CurrentRowAttProp
{
public static void SetCurrentRow(DependencyObject element, object value)
{
if (element is SfDataGrid || element is ListView)
element.SetValue(CurrentRowProperty, value);
else
throw new NotSupportedException("This property can be used only with SfDataGrid");
}
public static object GetCurrentRow(DependencyObject element)
{
return (object)element.GetValue(CurrentRowProperty);
}
public static readonly DependencyProperty CurrentRowProperty =
DependencyProperty.RegisterAttached("CurrentRow", typeof(object), typeof(CurrentRowAttProp), new PropertyMetadata(null, OnCellTapped));
private static void OnCellTapped(DependencyObject d, DependencyPropertyChangedEventArgs args)
{
if (d is SfDataGrid)
{
var sfDataGrid = d as SfDataGrid;
if (sfDataGrid == null)
return;
sfDataGrid.CellTapped += (sender, e) =>
{
CurrentRowAttProp.SetCurrentRow(sfDataGrid, e.Record);
};
}
}
}