private void ApplyContainerClip( DraggedElementAdorner adorner ) { if( adorner == null ) return; var adornedElement = adorner.AdornedElement; if( adornedElement == null ) return; // We only want to clip Cells other than the dragged Cell if( adornedElement == this.DraggedElement ) return; var dataGridContext = DataGridControl.GetDataGridContext( adornedElement ); if( dataGridContext == null ) return; var dataItemStore = CustomItemContainerGenerator.GetDataItemProperty( adornedElement ); if( ( dataItemStore == null ) || dataItemStore.IsEmpty ) return; var dataItem = dataItemStore.Data; if( dataItem == null ) return; var container = dataGridContext.GetContainerFromItem( dataItem ) as UIElement; if( container != null ) { RectangleGeometry containerClip = container.Clip as RectangleGeometry; if( containerClip != null ) { // Transform the bounds of the clip region of the container to fit the bounds of the adornedElement Rect transformedBounds = container.TransformToDescendant( adornedElement ).TransformBounds( containerClip.Bounds ); containerClip = new RectangleGeometry( transformedBounds ); } adorner.AdornedElementImage.Clip = containerClip; } else { //This is an item that is in the FixedHeaders/Footers of the gird, do not clip it. adorner.AdornedElementImage.Clip = null; } }
private void ApplyContainerClip( DraggedElementAdorner adorner ) { if( adorner == null ) return; UIElement adornedElement = adorner.AdornedElement; if( adornedElement == null ) return; // We only want to clip Cells other than the dragged Cell if( adornedElement == this.DraggedElement ) return; DataGridContext dataGridContext = DataGridControl.GetDataGridContext( adornedElement ); if( dataGridContext == null ) return; object dataItem = adornedElement.GetValue( CustomItemContainerGenerator.DataItemPropertyProperty ); if( dataItem == null ) return; UIElement container = dataGridContext.GetContainerFromItem( dataItem ) as UIElement; if( container != null ) { RectangleGeometry containerClip = container.Clip as RectangleGeometry; if( containerClip != null ) { // Transform the bounds of the clip region of the container to fit the bounds of the adornedElement Rect transformedBounds = container.TransformToDescendant( adornedElement ).TransformBounds( containerClip.Bounds ); containerClip = new RectangleGeometry( transformedBounds ); } adorner.AdornedElementImage.Clip = containerClip; } else { // Clip adorner completely adorner.AdornedElementImage.Clip = new RectangleGeometry( Rect.Empty ); } }