Exemple #1
0
        public static object FindStyleValue(object value, string propertyName, DependencyProperty defaultStyleDP, DependencyProperty columnStyleDP)
        {
            object _result = null;

            Style _defaultStyle = null;
            Style _columnStyle  = null;

            GridViewColumnHeader _header = null;
            DsxColumn            _column = null;

            if (value is DsxDataGrid)
            {
                _defaultStyle = (Style)((DsxDataGrid)value).GetValue(defaultStyleDP);
            }
            else if (value is GridViewColumnHeader)
            {
                _header = (GridViewColumnHeader)value;
                _column = (DsxColumn)_header.Column;
            }
            else
            {
                _column = (DsxColumn)value;
            }

            if (_column != null)
            {
                _defaultStyle = (Style)_column.DataGrid.GetValue(defaultStyleDP);
                _columnStyle  = (Style)_column.GetValue(columnStyleDP);
            }
            else if (_defaultStyle == null)
            {
                //  remind: padding empty columns have no column assigned in the GridViewColumnHeader

                DsxDataGrid _dataGrid = ElementHelper.FindLogicalParent <DsxDataGrid>(_header);
                if (_dataGrid != null)
                {
                    _defaultStyle = (Style)_dataGrid.GetValue(defaultStyleDP);
                }
            }

            //  apply current (column) Style
            //  fall back to default Style
            _result = _columnStyle.GetStylePropertyValue <object>(propertyName, _defaultStyle, null);

            return(_result);
        }
Exemple #2
0
        internal void UpdateRowArea(GridViewRowPresenter gridPresenter)
        {
            if (gridPresenter == null)
            {
                //  happens due to virutalization
                return;
            }

            ContentPresenter _cellContent = null;
            FrameworkElement _cellElement = null;

            for (int i = 0; i < gridPresenter.Columns.Count; i++)
            {
                _cellContent = VisualTreeHelper.GetChild(gridPresenter, i) as ContentPresenter;
                _cellElement = ElementHelper.FindVisualChild <FrameworkElement>(_cellContent);
                if (_cellElement != null)
                {
                    _cellElement.InvalidateMeasure();
                    _cellElement.InvalidateArrange();
                    _cellElement.UpdateLayout();
                }
            }
        }
Exemple #3
0
        void OnPreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (this.Column == null)
            {
                return;
            }

            if (this.Column.ViewType == EViewType.CheckBox)
            {
                e.Handled = true;
                return;
            }

            if (this.Column.EditType == EEditType.CellTemplate && this.IsEditMode)
            {
                e.Handled = false;
                return;
            }


            if (this.Column.CellContentIsClickable)
            {
                //   let the click trough on the first button found

                Button _button = ElementHelper.FindVisualChild <Button>(this);

                if (_button != null)
                {
                    Point         _point     = e.GetPosition((UIElement)sender);
                    HitTestResult _hitResult = VisualTreeHelper.HitTest(this, _point);
                    if (_hitResult != null)
                    {
                        Visual _hitElement = ElementHelper.FindVisualChild <Visual>(_button);

                        e.Handled = !(_hitElement == _hitResult.VisualHit);
                    }

                    // this way we could raise the button click event

                    //_button.RaiseEvent( new RoutedEventArgs(Button.ClickEvent));

                    //ButtonAutomationPeer _peerButton = new ButtonAutomationPeer(_button);
                    //IInvokeProvider      _invokeProv = _peerButton.GetPattern(PatternInterface.Invoke) as IInvokeProvider;
                    //                     _invokeProv.Invoke();
                }
            }
            else
            {
                e.Handled = true;

                if (this.Column.IsEditable)
                {
                    long _ticksPassed = DateTime.Now.Ticks - m_lastTicks;
                    if (_ticksPassed < 50000000)
                    {
                        m_lastTicks = 0;
                        this.Column.DataGrid.SetEditCell(this.Column, (FrameworkElement)this);
                        return;
                    }
                }
                m_lastTicks = DateTime.Now.Ticks;
            }
        }