internal DataGridContextAutomationPeer(
      DataGridControl dataGridControl,
      DataGridContext parentDataGridContext,
      object parentItem,
      DetailConfiguration detailConfiguration )
    {
      if( dataGridControl == null )
        throw new ArgumentNullException( "dataGridControl" );

      if( parentDataGridContext == null )
      {
        m_dataGridContext = dataGridControl.DataGridContext;
      }
      else
      {
        m_dataGridContext = parentDataGridContext.GetChildContext( parentItem, detailConfiguration );
      }

      if( m_dataGridContext != null )
        m_dataGridContext.Peer = this;

      m_dataGridControl = dataGridControl;
      m_parentDataGridContext = parentDataGridContext;
      m_parentItem = parentItem;
      m_detailConfiguration = detailConfiguration;

      m_dataChildren = new Hashtable( 0 );
      m_headerFooterChildren = new Hashtable( 0 );
    }
Ejemplo n.º 2
0
        protected override void EndEditCore()
        {
            DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this);

            base.EndEditCore();

            DataGridCollectionViewBase dataGridCollectionViewBase =
                (dataGridContext == null) ? null : dataGridContext.ItemsSourceCollection as DataGridCollectionViewBase;

            try
            {
                if (dataGridCollectionViewBase != null)
                {
                    if (dataGridCollectionViewBase.CurrentEditItem == this.DataContext)
                    {
                        dataGridCollectionViewBase.CommitEdit();
                    }
                }
                else
                {
                    IEditableObject editableObject = this.EditableObject;

                    // editableObject can be equal to this when the datarow is directly inserted as Items in the DataGridControl.
                    if ((editableObject != null) && (editableObject != this))
                    {
                        editableObject.EndEdit();
                    }
                }
            }
            catch (Exception exception)
            {
                // Note that we do not update the created cell's Content from the source in case the IEditableObject EndEdit implementation
                // throwed an exception.  This is mainly due because we want to make sure that we do not lose all of the edited cells values.
                // This way, the end user will have the chance to correct the mistakes without loosing everything he typed.

                // If EndEdit throwed, call BeginEdit on the IEditableObject to make sure that it stays in edit mode.
                // We don't have to do this when bound to a DataGridCollectionView since it will take care of it.
                if (dataGridCollectionViewBase == null)
                {
                    IEditableObject editableObject = this.EditableObject;

                    // editableObject can be equal to this when the datarow is directly inserted as Items in the DataGridControl.
                    if ((editableObject != null) && (editableObject != this))
                    {
                        editableObject.BeginEdit();
                    }
                }

                // This method will set a validation error on the row and throw back a DataGridValidationException so that
                // the row stays in edition.
                Row.SetRowValidationErrorOnException(this, exception);
            }

            // Update the created cell's Content from the source in case the IEditableObject EndEdit implementation rectified
            // some values.
            this.UpdateCellsContentBindingTarget();
        }
Ejemplo n.º 3
0
        private void OnExpandDetailsExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this);

            if ((dataGridContext != null) && (this.DataContext != null))
            {
                dataGridContext.ExpandDetails(this.DataContext);
            }
        }
        protected override void StopListening(object source)
        {
            DataGridControl dataGridControl = source as DataGridControl;

            if (dataGridControl != null)
            {
                dataGridControl.SelectionChanged -= this.DataGridControl_SelectionChanged;
            }
        }
Ejemplo n.º 5
0
        private static void CalculateIndexRange(DataGridControl grid, out int start, out int end)
        {
            ScrollViewer scroller = grid.Template.FindName("PART_ScrollViewer", grid) as ScrollViewer;

            start = (int)scroller.VerticalOffset;

            end = (int)(scroller.VerticalOffset + scroller.ViewportHeight);
            end = Math.Min(end, grid.Items.Count - 1);
        }
Ejemplo n.º 6
0
 private void RegisterListeners(DataGridControl parentGridControl)
 {
     if (parentGridControl.ScrollViewer != null)
     {
         parentGridControl.ScrollViewer.ScrollChanged += new ScrollChangedEventHandler(this.OnScrollViewerScrollChanged);
         m_scrollViewerTemplateHelper = new ScrollViewerTemplateHelper(parentGridControl.ScrollViewer, this.DragScrollBegin, this.DragScrollEnd);
         m_scrollViewerTemplateHelper.RefreshTemplate();
     }
 }
Ejemplo n.º 7
0
        private void Columns_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "MainColumn")
            {
                DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this);

                this.SetTitleBarContentBinding(dataGridContext);
            }
        }
Ejemplo n.º 8
0
        public override void Edit(object selectedItem)
        {
            DataRowView           item  = (DataRowView)selectedItem;
            MedicalTitleViewModel title = Mapping.Mapper.Map <MedicalTitleViewModel>(item);
            EditModalWindow       modal = new EditModalWindow(title);

            _ = modal.ShowDialog();
            DataGridControl.InformAboutStatus(modal.OperationStatus);
        }
Ejemplo n.º 9
0
        public override void Edit(object selectedItem)
        {
            DataRowView     item        = (DataRowView)selectedItem;
            PlaceViewModel  place       = Mapping.Mapper.Map <PlaceViewModel>(item);
            EditModalWindow modalWindow = new EditModalWindow(place);

            _ = modalWindow.ShowDialog();
            DataGridControl.InformAboutStatus(modalWindow.OperationStatus);
        }
Ejemplo n.º 10
0
        protected override Cell CreateCell(ColumnBase column)
        {
            if (column == null)
            {
                throw new DataGridInternalException("Column is null.", DataGridControl.GetDataGridContext(this).DataGridControl);
            }

            return(new DataCell());
        }
Ejemplo n.º 11
0
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonDown(e);

            if (!e.Handled)
            {
                e.Handled = DataGridControl.SetFocusUIElementHelper(this);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Check that valid locations in collection are valid.
        /// </summary>
        /// <returns>'True' if locations are valid, 'false' otherwise.</returns>
        private List <Location> _GetValidLocation()
        {
            var validLocations = new List <Location>();

            // Fill location collection which will be validate with
            // locations, which names are not whitespaces.
            List <Location> locationsToValidate = new List <Location>();

            foreach (var location in _locations)
            {
                if (location.Name == "" || location.Name.Trim().Length > 0)
                {
                    locationsToValidate.Add(location);
                }
            }

            // Check that there are locations to validate.
            if (locationsToValidate.Count == 0)
            {
                string message = ((string)App.Current.FindResource("NoLocationValidationError"));
                App.Current.Messenger.AddMessage(MessageType.Warning, message);

                //Return empty collection.
                return(validLocations);
            }
            // Add valid locations to result collection.
            else
            {
                foreach (var location in locationsToValidate)
                {
                    // Turn on validation for address fields.
                    if (!location.IsAddressValidationEnabled)
                    {
                        location.IsAddressValidationEnabled = true;

                        // Start then end edit. This will push grid to realize,
                        // that Addres field become invalid.
                        // NOTE: we can have exception here if edit is already in progress.
                        DataGridControl.BeginEdit(location);
                        DataGridControl.EndEdit();
                    }

                    if (location.IsValid)
                    {
                        validLocations.Add(location);
                    }
                }
            }

            // If there is no valid locations - show error message about invalid locations.
            if (validLocations.Count == 0)
            {
                CanBeLeftValidator <Location> .ShowErrorMessagesInMessageWindow(locationsToValidate);
            }

            return(validLocations);
        }
        internal static bool HandleTabKey(
            DataGridControl dataGridControl,
            DataGridContext dataGridContext,
            FrameworkElement source,
            KeyboardDevice device)
        {
            if ((dataGridControl == null) || !dataGridControl.IsKeyboardFocusWithin)
            {
                return(false);
            }

            Debug.Assert(dataGridControl.CurrentContext == dataGridContext);

            if (!dataGridControl.IsBeingEdited)
            {
                Debug.Assert(dataGridContext != null);
                return(false);
            }

            if (NavigationHelper.ValidateTabKeyHandleIsWithin(dataGridControl, source, device))
            {
                return(false);
            }

            var columns = dataGridContext.VisibleColumns;

            if (columns.Count <= 0)
            {
                return(false);
            }

            bool handled;

            if (dataGridContext.CurrentColumn == null)
            {
                handled = NavigationHelper.MoveFocusToFirstVisibleColumn(dataGridContext);
            }
            else
            {
                if ((device.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift)
                {
                    handled = NavigationHelper.MoveFocusToPreviousVisibleColumn(dataGridContext);
                }
                else
                {
                    handled = NavigationHelper.MoveFocusToNextVisibleColumn(dataGridContext);
                }
            }

            if (!handled)
            {
                throw new DataGridException("Trying to edit while no cell is focusable.", dataGridControl);
            }

            return(true);
        }
Ejemplo n.º 14
0
        public void Dispose()
        {
            if (PopupFilterSelected != null)
            {
                var popupChild = PopupFilterSelected.Child as IDisposable;
                if (popupChild != null)
                {
                    popupChild.Dispose();
                }
                PopupFilterSelected.Child = null;
            }

            if (_popupValidate != null)
            {
                _popupValidate.Child   = null;
                _popupValidate.Opened -= _popupValidate_Opened;
                _popupValidate.Closed -= _popupValidate_Opened;
            }

            if (_view != null)
            {
                _view.Filter -= MeterNumbersPredicateDelegate;
            }

            if (worker != null)
            {
                worker.CancelAsync();

                worker.DoWork             -= WorkerDoWork;
                worker.RunWorkerCompleted -= WorkerCompleted;
            }

            if (_selectedDateChangedDescriptor != null)
            {
                _selectedDateChangedDescriptor.RemoveValueChanged(dateStart, OnSelectedDateChanged);
                _selectedDateChangedDescriptor.RemoveValueChanged(dateEnd, OnSelectedDateChanged);
            }

            if (_grid != null)
            {
                _grid.ClearItems();

                if (_grid.DetailConfigurations != null)
                {
                    _grid.DetailConfigurations.Clear();
                }
            }

            listLevelsForMonitoring.ClearItems();

            layoutGrid.Children.Clear();

            _grid       = null;
            _view       = null;
            DataContext = null;
        }
 public IndexControl(IndexControlElement indexControlElement, DataGridControlElement dataGridControlElement, Visibility detailsBtnVisibility = Visibility.Hidden, Visibility crudBtnVisibility = Visibility.Visible)
 {
     InitializeComponent();
     this.IndexControlElement = indexControlElement;
     this.DataGridControl     = new DataGridControl(dataGridControlElement);
     DataContext = DataGridControl.DataGrid;
     this.detailsBtnVisibility = detailsBtnVisibility;
     this.crudBtnVisibility    = crudBtnVisibility;
     InitializeComponents();
 }
        public override async void Edit(object selectedItem)
        {
            DataRowView     item   = (DataRowView)selectedItem;
            ClinicViewModel clinic = Mapping.Mapper.Map <ClinicViewModel>(item);

            EditModalWindow modal = await EditModalWindow.Create(clinic);

            _ = modal.ShowDialog();
            DataGridControl.InformAboutStatus(modal.OperationStatus);
        }
Ejemplo n.º 17
0
        private static void OnParentGridControlChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            RowSelector     rowSelector = ( RowSelector )sender;
            DataGridControl newGrid     = e.NewValue as DataGridControl;

            if (newGrid != null)
            {
                rowSelector.PrepareDefaultStyleKey(newGrid.GetView());
            }
        }
        private static void ParentGridControlChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            DataGridControl parentDataGrid = e.NewValue as DataGridControl;
            HierarchicalGroupByControlNode groupByControl = ( HierarchicalGroupByControlNode )sender;

            if (parentDataGrid != null)
            {
                groupByControl.PrepareDefaultStyleKey(parentDataGrid.GetView());
            }
        }
Ejemplo n.º 19
0
        private static void OnParentGridControlChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            DataGridControl    grid = e.NewValue as DataGridControl;
            GroupHeaderControl groupHeaderControl = sender as GroupHeaderControl;

            if ((groupHeaderControl != null) && (grid != null))
            {
                groupHeaderControl.PrepareDefaultStyleKey(grid.GetView());
            }
        }
Ejemplo n.º 20
0
 protected override void OnEditEnded()
 {
     base.OnEditEnded();
     if (this.canCommit != null)
     {
         var gridContext = DataGridControl.GetDataGridContext(this);
         gridContext.Items.MoveCurrentTo(this.canCommit);
         this.canCommit = null;
     }
 }
Ejemplo n.º 21
0
        public override async void Edit(object selectedItem)
        {
            DataRowView            item  = (DataRowView)selectedItem;
            MedicalRecordViewModel model = Mapping.Mapper.Map <MedicalRecordViewModel>(item);

            EditModalWindow modalWindow = await EditModalWindow.Create(model);

            _ = modalWindow.ShowDialog();
            DataGridControl.InformAboutStatus(modalWindow.OperationStatus);
        }
Ejemplo n.º 22
0
        private static void ParentGridControlChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            DataGridControl grid  = e.NewValue as DataGridControl;
            GroupByControl  panel = ( GroupByControl )sender;

            if (grid != null)
            {
                panel.PrepareDefaultStyleKey(grid.GetView());
            }
        }
Ejemplo n.º 23
0
 public void Register(DataGridControl ic)
 {
     if (ic != null)
     {
         myObj = ic;
         myObj.PreviewMouseMove           += PreviewMouseMove;
         myObj.PreviewMouseLeftButtonDown += PreviewMouseLeftButtonDown;
         myObj.SelectionMode = SelectionMode.Extended;
     }
 }
        protected override void ClearContainer()
        {
            var item = this.DataContext;

            PropertyChangedEventManager.RemoveListener(item as INotifyPropertyChanged, this, "IsSelected");

            var selectedItems = DataGridControl.GetDataGridContext(this).SelectedItems.Remove(item);

            base.ClearContainer();
        }
Ejemplo n.º 25
0
        public override void Delete(object selectedItem)
        {
            DataRowView            item  = (DataRowView)selectedItem;
            MedicalRecordViewModel model = Mapping.Mapper.Map <MedicalRecordViewModel>(item);

            DeleteModalWindow modalWindow = new DeleteModalWindow(model);

            _ = modalWindow.ShowDialog();
            DataGridControl.InformAboutStatus(modalWindow.OperationStatus);
        }
        public override void Delete(object selectedItem)
        {
            DataRowView   item = (DataRowView)selectedItem;
            RoleViewModel role = Mapping.Mapper.Map <RoleViewModel>(item);

            DeleteModalWindow deleteModal = new DeleteModalWindow(role);

            _ = deleteModal.ShowDialog();
            DataGridControl.InformAboutStatus(deleteModal.OperationStatus);
        }
Ejemplo n.º 27
0
        public static ContextMenu Generate <T>(this DataGridControl dgcGridControl) where T : class
        {
            var menu = new ContextMenu();

            dgcGridControl.GenerateColumnsVisibilityMenu(menu);

            var root = new MenuItem {
                Header = "Copy"
            };

            menu.Items.Add(root);

            var type    = typeof(T);
            var members = type.GetProperties();

            foreach (var propertyInfo in members)
            {
                var attr = Attribute.GetCustomAttribute(propertyInfo, typeof(EnableCopyAttribute));
                if (attr != null)
                {
                    var item = new MenuItem {
                        Header = propertyInfo.Name
                    };

                    var info = propertyInfo;
                    item.Click += (s, e) =>
                    {
                        var si = dgcGridControl.SelectedItem as T;

                        if (si != null)
                        {
                            try
                            {
                                var val = info.GetValue(si);

                                if (val != null)
                                {
                                    Clipboard.Clear();
                                    Clipboard.SetText(val.ToString());
                                }
                            }
                            catch (Exception ex)
                            {
                                var log = LogFactory.Create(typeof(GridHelper));
                                log.Error(ex);
                            }
                        }
                    };

                    root.Items.Add(item);
                }
            }

            return(menu);
        }
Ejemplo n.º 28
0
        protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            bool isMouseCaptured = this.IsMouseCaptured;
            bool isPressed       = this.IsPressed;

            if (m_dragSourceManager != null)
            {
                m_dragSourceManager.Drop(e);
            }

            if (isMouseCaptured)
            {
                this.ReleaseMouseCapture();

                bool click = isPressed;

                if (click)
                {
                    bool           allowSort = true;
                    GroupByControl parentGBC = this.GetParentGroupByControl();

                    if (parentGBC != null)
                    {
                        allowSort = parentGBC.AllowSort;
                    }

                    if (allowSort)
                    {
                        DataGridContext       dataGridContext = DataGridControl.GetDataGridContext(this);
                        GroupLevelDescription groupInfo       = this.Content as GroupLevelDescription;
                        Debug.Assert((dataGridContext != null) && (groupInfo != null));

                        if ((dataGridContext != null) && (groupInfo != null))
                        {
                            ColumnBase column = dataGridContext.Columns[groupInfo.FieldName];

                            if ((column != null) && (column.AllowSort))
                            {
                                bool shiftUnpressed = ((Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.Shift);

                                var toggleColumnSort = dataGridContext.ToggleColumnSortCommand;
                                if (toggleColumnSort.CanExecute(column, shiftUnpressed))
                                {
                                    toggleColumnSort.Execute(column, shiftUnpressed);
                                }

                                e.Handled = true;
                            }
                        }
                    }
                }
            }

            base.OnMouseLeftButtonUp(e);
        }
Ejemplo n.º 29
0
        private static void ParentGridControlPropertyChangedCallback(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            DataGridControl oldParentGridControl = e.OldValue as DataGridControl;
            DataGridControl parentGridControl    = e.NewValue as DataGridControl;
            ScrollTip       scrollTip            = sender as ScrollTip;

            scrollTip.IsInParentGridChanged = true;
            try
            {
                if (oldParentGridControl != null)
                {
                    if (scrollTip.UsingDefaultScrollTipContentTemplate)
                    {
                        // Unload DefaultTemplate
                        Nequeo.Wpf.DataGrid.Views.UIViewBase uiViewBase = oldParentGridControl.GetView() as Nequeo.Wpf.DataGrid.Views.UIViewBase;

                        if (uiViewBase != null)
                        {
                            uiViewBase.ClearValue(UIViewBase.ScrollTipContentTemplateProperty);
                            scrollTip.UsingDefaultScrollTipContentTemplate = false;
                        }
                    }

                    if (scrollTip.m_mainColumn != null)
                    {
                        PropertyChangedEventManager.RemoveListener(scrollTip.m_mainColumn, scrollTip, "DisplayMemberBinding");
                    }

                    scrollTip.m_mainColumn = null;

                    scrollTip.UnregisterListeners(oldParentGridControl);
                }

                if (parentGridControl == null)
                {
                    return;
                }

                scrollTip.PrepareDefaultStyleKey(parentGridControl.GetView());

                // Assert Template is applied in order to be notified for ScrollBars events
                DataGridControl.SetDataGridContext(scrollTip, parentGridControl.DataGridContext);

                if (!scrollTip.ApplyTemplate())
                {
                    scrollTip.RefreshDefaultScrollTipContentTemplate();
                }

                scrollTip.RegisterListeners(parentGridControl);
            }
            finally
            {
                scrollTip.IsInParentGridChanged = false;
            }
        }
    protected override Size MeasureOverride( Size availableSize )
    {
      var panel = this.GroupLevelIndicatorPaneHost;
      if( panel == null )
        return base.MeasureOverride( availableSize );

      var dataGridContext = DataGridControl.GetDataGridContext( this );
      if( ( dataGridContext == null ) || !this.GroupLevelIndicatorPaneNeedsRefresh )
        return base.MeasureOverride( availableSize );

      //clear all the panel's children!
      panel.Children.Clear();

      var previousContext = dataGridContext;
      var runningDataGridContext = dataGridContext.ParentDataGridContext;

      while( runningDataGridContext != null )
      {
        //create a GroupLevelIndicator to create indentation between the GLIPs
        FrameworkElement newGroupMargin = new DetailIndicator();
        newGroupMargin.DataContext = dataGridContext;

        object bindingSource = dataGridContext.GetDefaultDetailConfigurationForContext();
        if( bindingSource == null )
        {
          bindingSource = dataGridContext.SourceDetailConfiguration;
        }

        //Bind the GroupLevelIndicator`s style to the running DataGridContext`s GroupLevelIndicatorStyle.
        var groupLevelIndicatorStyleBinding = new Binding();
        groupLevelIndicatorStyleBinding.Path = new PropertyPath( DetailConfiguration.DetailIndicatorStyleProperty );
        groupLevelIndicatorStyleBinding.Source = bindingSource;
        newGroupMargin.SetBinding( StyleProperty, groupLevelIndicatorStyleBinding );

        //insert the Spacer GroupLevelIndicator in the panel
        panel.Children.Insert( 0, newGroupMargin );

        if( !runningDataGridContext.AreDetailsFlatten )
        {
          //then create the GLIP for the running DataGridContext
          var newSubGLIP = new GroupLevelIndicatorPane();
          DataGridControl.SetDataGridContext( newSubGLIP, runningDataGridContext );
          newSubGLIP.SetIsLeaf( false );
          GroupLevelIndicatorPane.SetGroupLevel( newSubGLIP, -1 );

          //and insert it in the panel.
          panel.Children.Insert( 0, newSubGLIP );
        }

        previousContext = runningDataGridContext;
        runningDataGridContext = runningDataGridContext.ParentDataGridContext;
      }

      return base.MeasureOverride( availableSize );
    }
Ejemplo n.º 31
0
 private void ff_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     control   = sender as DataGridControl;
     this.inpc = e.NewValue as INotifyPropertyChanged;
     if (this.inpc != null)
     {
         this.propInfo = e.NewValue.GetType().GetProperty(this.Path);
         Debug.WriteLine("New DataContext: {0}", e.NewValue);
         this.inpc.PropertyChanged += this.inpc_PropertyChanged;
     }
 }
    internal static IDataObject CreateDataObject( DataGridControl dataGridControl )
    {
      if( dataGridControl == null )
        throw new ArgumentNullException( "dataGridControl" );

      DataGridContext dataGridContext = DataGridControl.GetDataGridContext( dataGridControl );

      if( dataGridContext == null )
        return null;

      XceedDataObject dataObject = null;
      bool containsData = false;

      try
      {
        dataGridControl.ShowWaitCursor();

        Dictionary<string, ClipboardExporterBase> exporters = dataGridControl.ClipboardExporters;

        foreach( KeyValuePair<string, ClipboardExporterBase> keyPair in exporters )
        {
          if( keyPair.Value == null )
            throw new DataGridException( "ClipboardExporterBase cannot be null." );

          keyPair.Value.StartExporter( keyPair.Key );
        }

        using( ManualExporter exporter = new ManualExporter( exporters.Values as IEnumerable<ClipboardExporterBase> ) )
        {
          exporter.Export( dataGridContext );
        }

        foreach( KeyValuePair<string, ClipboardExporterBase> keyPair in exporters )
        {
          keyPair.Value.EndExporter( keyPair.Key );

          if( dataObject == null )
          {
            dataObject = new XceedDataObject();
          }

          object clipboardExporterValue = keyPair.Value.ClipboardData;

          // For other formats, we directly copy the content to the IDataObject
          if( clipboardExporterValue != null )
          {
            ( ( IDataObject )dataObject ).SetData( keyPair.Key, clipboardExporterValue );
            containsData = true;
          }

          keyPair.Value.ResetExporter();
        }
      }
      finally
      {
        dataGridControl.HideWaitCursor();
      }

      // Only return dataObject some data was copied
      if( containsData )
        return dataObject as IDataObject;

      return null;
    }
 public DataGridControlAutomationPeer( DataGridControl owner )
   : base( owner )
 {
   m_innerDataGridContextAutomationPeer = new DataGridContextAutomationPeer( owner, null, null, null );
   m_innerDataGridContextAutomationPeer.EventsSource = this;
 }
    protected override void OnParentDataGridControlChanged( DataGridControl oldValue, DataGridControl newValue )
    {
      // Ensure to stop any animation since this ItemsHost
      // is no more hosted in a DataGridControl
      if( newValue == null )
      {
        // Stop the AnimationClock for each offset property
        this.StopVerticalOffsetAnimation();
        this.StopHorizontalOffsetAnimation();

        // Ensure to clear any animation on offset property directly
        this.ApplyAnimationClock( TableflowViewItemsHost.AnimatedVerticalOffsetProperty, null, HandoffBehavior.SnapshotAndReplace );
        this.ApplyAnimationClock( TableflowViewItemsHost.AnimatedHorizontalOffsetProperty, null, HandoffBehavior.SnapshotAndReplace );
      }

      base.OnParentDataGridControlChanged( oldValue, newValue );
    }
    private static bool ValidateTabKeyHandleIsWithin(
      DataGridControl dataGridControl,
      FrameworkElement source,
      KeyboardDevice device )
    {
      if( ( dataGridControl == null ) || ( source == null ) )
        return false;

      var nextControl = NavigationHelper.PredictNextElement( source, device );
      if( nextControl == null )
        return false;

      //If the original source is not a control (e.g. the cells panel instead of a cell), columns will be used to move focus.
      var cell = Cell.FindFromChild( nextControl );
      if( ( cell == null ) || ( cell.ParentColumn != dataGridControl.CurrentColumn ) )
        return false;

      return object.Equals( cell.ParentRow.DataContext, dataGridControl.CurrentItemInEdition );
    }
    private static bool MoveFocus( DataGridControl dataGridControl, DataGridContext dataGridContext, bool moveLeft )
    {
      Debug.Assert( dataGridControl != null );
      Debug.Assert( dataGridControl.CurrentContext == dataGridContext );

      bool isFocusWithin = dataGridControl.IsKeyboardFocusWithin;
      bool isBeingEdited = ( isFocusWithin && dataGridControl.IsBeingEdited );

      var navigationBehavior = dataGridControl.NavigationBehavior;

      // Process key even if NavigationBehavior is RowOnly when the grid is being edited.
      if( ( navigationBehavior == NavigationBehavior.CellOnly )
        || ( ( navigationBehavior == NavigationBehavior.RowOnly ) && isBeingEdited )
        || ( ( navigationBehavior == NavigationBehavior.RowOrCell ) && isFocusWithin && ( dataGridContext.CurrentColumn != null ) ) )
      {
        if( moveLeft )
          return NavigationHelper.MoveFocusToPreviousVisibleColumn( dataGridContext, dataGridContext.CurrentRow, dataGridContext.CurrentColumn );

        return NavigationHelper.MoveFocusToNextVisibleColumn( dataGridContext, dataGridContext.CurrentRow, dataGridContext.CurrentColumn );
      }

      return false;
    }
    internal static bool HandleTabKey(
      DataGridControl dataGridControl,
      DataGridContext dataGridContext,
      FrameworkElement source,
      KeyboardDevice device )
    {
      if( ( dataGridControl == null ) || !dataGridControl.IsKeyboardFocusWithin )
        return false;

      Debug.Assert( dataGridControl.CurrentContext == dataGridContext );

      if( !dataGridControl.IsBeingEdited )
      {
        Debug.Assert( dataGridContext != null );
        return false;
      }

      if( NavigationHelper.ValidateTabKeyHandleIsWithin( dataGridControl, source, device ) )
        return false;

      var columns = dataGridContext.VisibleColumns;
      if( columns.Count <= 0 )
        return false;

      bool handled;

      if( dataGridContext.CurrentColumn == null )
      {
        handled = NavigationHelper.MoveFocusToFirstVisibleColumn( dataGridContext );
      }
      else
      {
        if( ( device.Modifiers & ModifierKeys.Shift ) == ModifierKeys.Shift )
        {
          handled = NavigationHelper.MoveFocusToPreviousVisibleColumn( dataGridContext );
        }
        else
        {
          handled = NavigationHelper.MoveFocusToNextVisibleColumn( dataGridContext );
        }
      }

      if( !handled )
        throw new DataGridException( "Trying to edit while no cell is focusable.", dataGridControl );

      return true;
    }