this.SfdataGrid.CurrentCellBeginEdit += SfdataGrid_CurrentCellBeginEdit;
this.SfdataGrid.CurrentCellEndEdit += SfdataGrid_CurrentCellEndEdit;
this.SfdataGrid.Loaded += SfdataGrid_Loaded;
/// <summary>
/// Open the PopUp and places based on cell's position
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
private void SfdataGrid_CurrentCellBeginEdit(object sender, CurrentCellBeginEditEventArgs args)
{
var rowline = this.SfdataGrid.GetVisualContainer().ScrollRows.GetVisibleLineAtLineIndex(args.RowColumnIndex.RowIndex);
var colline = this.SfdataGrid.GetVisualContainer().ScrollColumns.GetVisibleLineAtLineIndex(args.RowColumnIndex.ColumnIndex);
popUP.PlacementTarget = this.SfdataGrid.GetVisualContainer();
popUP.Placement = PlacementMode.Relative;
popUP.HorizontalOffset = colline.ClippedOrigin;
popUP.VerticalOffset = rowline.ClippedOrigin;
popUP.IsOpen = true;
}
/// <summary>
/// Closes the PopUp.
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
private void SfdataGrid_CurrentCellEndEdit(object sender, CurrentCellEndEditEventArgs args)
{
popUP.IsOpen = false;
}
private void SfdataGrid_Loaded(object sender, RoutedEventArgs e)
{
this.SfdataGrid.GetVisualContainer().ScrollOwner.ScrollChanged += ScrollOwner_ScrollChanged;
}
/// <summary>
/// Update the PopUp position while scrolling.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ScrollOwner_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
var currentcell = SfdataGrid.SelectionController.CurrentCellManager;
if (!currentcell.HasCurrentCell)
{
popUP.IsOpen = false;
return;
}
var rowline = this.SfdataGrid.GetVisualContainer().ScrollRows.GetVisibleLineAtLineIndex(currentcell.CurrentRowColumnIndex.RowIndex);
var colline = this.SfdataGrid.GetVisualContainer().ScrollColumns.GetVisibleLineAtLineIndex(currentcell.CurrentRowColumnIndex.ColumnIndex);
if (rowline == null || colline == null)
{
popUP.IsOpen = false;
return;
}
popUP.HorizontalOffset = colline.ClippedOrigin;
popUP.VerticalOffset = rowline.ClippedOrigin;
popUP.IsOpen = true;
}
|