Browse Source

Remove commented-out code on DataGrid.

pull/2109/head
Jumar Macato 7 years ago
parent
commit
1d9593a238
No known key found for this signature in database GPG Key ID: B19884DAC3A5BF3F
  1. 109
      src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs
  2. 1088
      src/Avalonia.Controls.DataGrid/DataGrid.cs
  3. 161
      src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs
  4. 117
      src/Avalonia.Controls.DataGrid/DataGridCell.cs
  5. 180
      src/Avalonia.Controls.DataGrid/DataGridColumn.cs
  6. 1
      src/Avalonia.Controls.DataGrid/DataGridColumnCollection.cs
  7. 220
      src/Avalonia.Controls.DataGrid/DataGridColumnHeader.cs
  8. 52
      src/Avalonia.Controls.DataGrid/DataGridColumns.cs
  9. 12
      src/Avalonia.Controls.DataGrid/DataGridDataConnection.cs
  10. 11
      src/Avalonia.Controls.DataGrid/DataGridError.cs
  11. 1
      src/Avalonia.Controls.DataGrid/DataGridFillerColumn.cs
  12. 1
      src/Avalonia.Controls.DataGrid/DataGridLength.cs
  13. 373
      src/Avalonia.Controls.DataGrid/DataGridRow.cs
  14. 88
      src/Avalonia.Controls.DataGrid/DataGridRowGroupHeader.cs
  15. 283
      src/Avalonia.Controls.DataGrid/DataGridRowHeader.cs
  16. 45
      src/Avalonia.Controls.DataGrid/DataGridRows.cs
  17. 4
      src/Avalonia.Controls.DataGrid/DataGridSelectedItemsCollection.cs
  18. 1
      src/Avalonia.Controls.DataGrid/DataGridTemplateColumn.cs
  19. 24
      src/Avalonia.Controls.DataGrid/DataGridTextColumn.cs
  20. 5
      src/Avalonia.Controls.DataGrid/EventArgs.cs
  21. 2
      src/Avalonia.Controls.DataGrid/Extensions.cs
  22. 2
      src/Avalonia.Controls.DataGrid/Primitives/DataGridCellsPresenter.cs
  23. 8
      src/Avalonia.Controls.DataGrid/Primitives/DataGridColumnHeadersPresenter.cs
  24. 5
      src/Avalonia.Controls.DataGrid/Primitives/DataGridDetailsPresenter.cs
  25. 9
      src/Avalonia.Controls.DataGrid/Primitives/DataGridRowsPresenter.cs
  26. 2
      src/Avalonia.Controls.DataGrid/Range.cs
  27. 2
      src/Avalonia.Controls.DataGrid/Utils/CellEditBinding.cs
  28. 1
      src/Avalonia.Controls.DataGrid/Utils/ReflectionHelper.cs
  29. 1
      src/Avalonia.Themes.Default/DataGrid.xaml

109
src/Avalonia.Controls.DataGrid/Collections/DataGridCollectionView.cs

@ -265,13 +265,6 @@ namespace Avalonia.Collections
#region Private Delegates
// / <summary>
// / Delegate used to asynchronously trigger a page move.
// / </summary>
// / <param name="pageIndex">Requested page index</param>
//TODO Not Needed?
//private delegate void RequestPageMoveDelegate(int pageIndex);
#endregion Private Delegates
#region Events
@ -1003,13 +996,7 @@ namespace Avalonia.Collections
}
}
#endregion Public Properties
////------------------------------------------------------
////
//// Private Properties
////
////------------------------------------------------------
#endregion Public Properties
#region Private Properties
@ -1188,13 +1175,7 @@ namespace Avalonia.Collections
get { return SortDescriptions.Count > 0 || Filter != null || _pageSize > 0 || GroupDescriptions.Count > 0; }
}
#endregion Private Properties
////------------------------------------------------------
////
//// Indexers
////
////------------------------------------------------------
#endregion Private Properties
#region Indexers
@ -1208,13 +1189,7 @@ namespace Avalonia.Collections
get { return GetItemAt(index); }
}
#endregion Indexers
////------------------------------------------------------
////
//// Public Methods
////
////------------------------------------------------------
#endregion Indexers
#region Public Methods
@ -2520,12 +2495,6 @@ namespace Avalonia.Collections
#endregion Public Methods
////------------------------------------------------------
////
//// Static Methods
////
////------------------------------------------------------
#region Static Methods
/// <summary>
@ -2547,12 +2516,6 @@ namespace Avalonia.Collections
#endregion Static Methods
////------------------------------------------------------
////
//// Private Methods
////
////------------------------------------------------------
#region Private Methods
/// <summary>
@ -3425,13 +3388,6 @@ namespace Avalonia.Collections
}
}
// if we need to add the item into the current group
// that will be displayed
//if (needsGrouping)
//{
// _group.AddToSubgroups(addedItem, false /*loading*/);
//}
int addedIndex = IndexOf(addedItem);
// if the item is within the current page
@ -3457,7 +3413,7 @@ namespace Avalonia.Collections
{
// otherwise if the item was added into a previous page
int internalIndex = InternalIndexOf(addedItem);
//int internalIndex = IsGrouping ? _group.LeafIndexOf(addedItem) : InternalIndexOf(addedItem);
if (internalIndex < ConvertToInternalIndex(0))
{
// fire add notification for item pushed in
@ -4030,23 +3986,8 @@ namespace Avalonia.Collections
foreach (DataGridSortDescription sort in SortDescriptions)
{
sort.Initialize(itemType);
//string propertyPath = sort.PropertyName;
//Type propertyType = null;
// find the propertyType from the first non-null instance
// in the list
//foreach (object item in list)
//{
// if (item != null)
// {
// propertyType = item.GetType().GetNestedPropertyType(propertyPath);
// break;
// }
//}
//IOrderedEnumerable<object> orderedEnum = seq as IOrderedEnumerable<object>;
sort.Initialize(itemType);
if(seq is IOrderedEnumerable<object> orderedEnum)
{
seq = sort.ThenBy(orderedEnum);
@ -4055,38 +3996,6 @@ namespace Avalonia.Collections
{
seq = sort.OrderBy(seq);
}
//switch (sort.Direction)
//{
// case System.ComponentModel.ListSortDirection.Ascending:
// if (orderedEnum != null)
// {
// // thenby
// seq = orderedEnum.ThenBy(item => InvokePath(item, propertyPath, propertyType), comparer);
// }
// else
// {
// // orderby
// seq = seq.OrderBy(item => InvokePath(item, propertyPath, propertyType), comparer);
// }
// break;
// case System.ComponentModel.ListSortDirection.Descending:
// if (orderedEnum != null)
// {
// // thenby
// seq = orderedEnum.ThenByDescending(item => InvokePath(item, propertyPath, propertyType), comparer);
// }
// else
// {
// // orderby
// seq = seq.OrderByDescending(item => InvokePath(item, propertyPath, propertyType), comparer);
// }
// break;
// default:
// break;
//}
}
return seq.ToList();
@ -4109,12 +4018,6 @@ namespace Avalonia.Collections
#endregion Private Methods
////------------------------------------------------------
////
//// Private Classes
////
////------------------------------------------------------
#region Private Classes
/// <summary>

1088
src/Avalonia.Controls.DataGrid/DataGrid.cs

File diff suppressed because it is too large

161
src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs

@ -59,13 +59,7 @@ namespace Avalonia.Controls
{
binding.Converter = DataGridValueConverter.Instance;
}
}
//// Setup the binding for validation
//_binding.ValidatesOnDataErrors = true;
//_binding.ValidatesOnExceptions = true;
//_binding.NotifyOnValidationError = true;
//_binding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
}
// Apply the new Binding to existing rows in the DataGrid
if (OwningGrid != null)
@ -103,14 +97,8 @@ namespace Avalonia.Controls
editBinding = null;
if (Binding != null)
//if (Binding != null || !DesignerProperties.IsInDesignTool)
{
//var t1 = Binding.Initiate(textBox, BindingTarget, anchor: null, enableDataValidation: true);
//BindingOperations.Apply(textBox, BindingTarget, t1, null);
editBinding = BindEditingElement(element, BindingTarget, Binding);
//element.Bind(BindingTarget, Binding);
//textBox.SetBinding(BindingTarget, Binding);
}
return element;
@ -136,56 +124,6 @@ namespace Avalonia.Controls
return null;
}
/*
public static IDisposable Apply(
IAvaloniaObject target,
AvaloniaProperty property,
InstancedBinding binding,
object anchor)
{
Contract.Requires<ArgumentNullException>(target != null);
Contract.Requires<ArgumentNullException>(property != null);
Contract.Requires<ArgumentNullException>(binding != null);
var mode = binding.Mode;
if (mode == BindingMode.Default)
{
mode = property.GetMetadata(target.GetType()).DefaultBindingMode;
}
switch (mode)
{
case BindingMode.Default:
case BindingMode.OneWay:
return target.Bind(property, binding.Observable ?? binding.Subject, binding.Priority);
case BindingMode.TwoWay:
return new CompositeDisposable(
target.Bind(property, binding.Subject, binding.Priority),
target.GetObservable(property).Subscribe(binding.Subject));
case BindingMode.OneTime:
var source = binding.Subject ?? binding.Observable;
if (source != null)
{
return source
.Where(x => BindingNotification.ExtractValue(x) != AvaloniaProperty.UnsetValue)
.Take(1)
.Subscribe(x => target.SetValue(property, x, binding.Priority));
}
else
{
target.SetValue(property, binding.Value, binding.Priority);
return Disposable.Empty;
}
case BindingMode.OneWayToSource:
return target.GetObservable(property).Subscribe(binding.Subject);
default:
throw new ArgumentException("Invalid binding mode.");
}
*/
protected abstract IControl GenerateEditingElementDirect(DataGridCell cell, object dataItem);
@ -206,108 +144,11 @@ namespace Avalonia.Controls
}
}
/*
[StyleTypedProperty(Property = "ElementStyle", StyleTargetType = typeof(FrameworkElement))]
[StyleTypedProperty(Property = "EditingElementStyle", StyleTargetType = typeof(FrameworkElement))]
*/
#region Binding
/*internal override List<string> CreateBindingPaths()
{
if (Binding != null && Binding.Path != null)
{
return new List<string>() { Binding.Path.Path };
}
return base.CreateBindingPaths();
}*/
/*internal override List<BindingInfo> CreateBindings(FrameworkElement element, object dataItem, bool twoWay)
{
BindingInfo bindingData = new BindingInfo();
if (twoWay && BindingTarget != null)
{
bindingData.BindingExpression = element.GetBindingExpression(BindingTarget);
if (bindingData.BindingExpression != null)
{
bindingData.BindingTarget = BindingTarget;
bindingData.Element = element;
return new List<BindingInfo> { bindingData };
}
}
foreach (DependencyProperty bindingTarget in element.GetDependencyProperties(false))
{
bindingData.BindingExpression = element.GetBindingExpression(bindingTarget);
if (bindingData.BindingExpression != null
&& bindingData.BindingExpression.ParentBinding == Binding)
{
BindingTarget = bindingTarget;
bindingData.BindingTarget = BindingTarget;
bindingData.Element = element;
return new List<BindingInfo> { bindingData };
}
}
return base.CreateBindings(element, dataItem, twoWay);
}*/
#endregion
#region Styles
//TODO Styles
/*
private Style _elementStyle;
private Style _editingElementStyle;
*/
/// <summary>
/// Gets or sets the style that is used when rendering the element that the column displays for a cell in editing mode.
/// </summary>
/*public Style EditingElementStyle
{
get
{
return _editingElementStyle;
}
set
{
if (_editingElementStyle != value)
{
_editingElementStyle = value;
// We choose not to update the elements already editing in the Grid here. They
// will get the EditingElementStyle next time they go into edit mode
}
}
}*/
/// <summary>
/// Gets or sets the style that is used when rendering the element that the column displays for a cell
/// that is not in editing mode.
/// </summary>
/*public Style ElementStyle
{
get
{
return _elementStyle;
}
set
{
if (_elementStyle != value)
{
_elementStyle = value;
if (OwningGrid != null)
{
OwningGrid.OnColumnElementStyleChanged(this);
}
}
}
}*/
#endregion
}

117
src/Avalonia.Controls.DataGrid/DataGridCell.cs

@ -182,72 +182,7 @@ namespace Avalonia.Controls
internal void UpdatePseudoClasses()
{
/*
if (OwningGrid == null || OwningColumn == null || OwningRow == null || OwningRow.Visibility == Visibility.Collapsed || OwningRow.Slot == -1)
{
return;
}
// CommonStates
if (IsMouseOver)
{
VisualStates.GoToState(this, animate, VisualStates.StateMouseOver, VisualStates.StateNormal);
}
else
{
VisualStates.GoToState(this, animate, VisualStates.StateNormal);
}
// SelectionStates
if (OwningRow.IsSelected)
{
VisualStates.GoToState(this, animate, VisualStates.StateSelected, VisualStates.StateUnselected);
}
else
{
VisualStates.GoToState(this, animate, VisualStates.StateUnselected);
}
// FocusStates
if (OwningGrid.ContainsFocus)
{
VisualStates.GoToState(this, animate, VisualStates.StateFocused, VisualStates.StateUnfocused);
}
else
{
VisualStates.GoToState(this, animate, VisualStates.StateUnfocused);
}
// CurrentStates
if (IsCurrent)
{
VisualStates.GoToState(this, animate, VisualStates.StateCurrent, VisualStates.StateRegular);
}
else
{
VisualStates.GoToState(this, animate, VisualStates.StateRegular);
}
// Interaction states
if (IsEdited)
{
VisualStates.GoToState(this, animate, VisualStates.StateEditing, VisualStates.StateDisplay);
}
else
{
VisualStates.GoToState(this, animate, VisualStates.StateDisplay);
}
// Validation states
if (IsValid)
{
VisualStates.GoToState(this, animate, VisualStates.StateValid);
}
else
{
VisualStates.GoToState(this, animate, VisualStates.StateInvalid, VisualStates.StateValid);
}
*/
}
// Makes sure the right gridline has the proper stroke and visibility. If lastVisibleColumn is specified, the
@ -283,53 +218,5 @@ namespace Avalonia.Controls
Classes.Replace(column.CellStyleClasses);
}
}
}
/*
[TemplatePart(Name = DATAGRIDCELL_elementRightGridLine, Type = typeof(Rectangle))]
[TemplateVisualState(Name = VisualStates.StateNormal, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = VisualStates.StateMouseOver, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = VisualStates.StateUnselected, GroupName = VisualStates.GroupSelection)]
[TemplateVisualState(Name = VisualStates.StateSelected, GroupName = VisualStates.GroupSelection)]
[TemplateVisualState(Name = VisualStates.StateUnfocused, GroupName = VisualStates.GroupFocus)]
[TemplateVisualState(Name = VisualStates.StateFocused, GroupName = VisualStates.GroupFocus)]
[TemplateVisualState(Name = VisualStates.StateRegular, GroupName = VisualStates.GroupCurrent)]
[TemplateVisualState(Name = VisualStates.StateCurrent, GroupName = VisualStates.GroupCurrent)]
[TemplateVisualState(Name = VisualStates.StateDisplay, GroupName = VisualStates.GroupInteraction)]
[TemplateVisualState(Name = VisualStates.StateEditing, GroupName = VisualStates.GroupInteraction)]
[TemplateVisualState(Name = VisualStates.StateInvalid, GroupName = VisualStates.GroupValidation)]
[TemplateVisualState(Name = VisualStates.StateValid, GroupName = VisualStates.GroupValidation)]
public sealed partial class DataGridCell : ContentControl
*/
//TODO Styles
/// <summary>
/// Ensures that the correct Style is applied to this object.
/// </summary>
/// <param name="previousStyle">Caller's previous associated Style</param>
/*internal void EnsureStyle(Style previousStyle)
{
if (Style != null
&& (OwningColumn == null || Style != OwningColumn.CellStyle)
&& (OwningGrid == null || Style != OwningGrid.CellStyle)
&& (Style != previousStyle))
{
return;
}
Style style = null;
if (OwningColumn != null)
{
style = OwningColumn.CellStyle;
}
if (style == null && OwningGrid != null)
{
style = OwningGrid.CellStyle;
}
SetStyleWithType(style);
} */
}
}

180
src/Avalonia.Controls.DataGrid/DataGridColumn.cs

@ -20,14 +20,6 @@ namespace Avalonia.Controls
internal const int DATAGRIDCOLUMN_maximumWidth = 65536;
private const bool DATAGRIDCOLUMN_defaultIsReadOnly = false;
/*
private List<string> _bindingPaths;
private Style _cellStyle;
private Style _dragIndicatorStyle;
private Style _headerStyle;
private List<BindingInfo> _inputBindings;
*/
private DataGridLength? _width; // Null by default, null means inherit the Width from the DataGrid
private bool? _isReadOnly;
private double? _maxWidth;
@ -995,28 +987,7 @@ namespace Avalonia.Controls
{
_editingElement = GenerateEditingElement(cell, dataItem, out _editBinding);
}
//if (_inputBindings == null && _editingElement != null)
//{
// //TODO: Binding ParameterNames
// _inputBindings = CreateBindings(_editingElement, dataItem, true);
// // Setup all of the active input bindings to support validation
// foreach (BindingInfo bindingData in _inputBindings)
// {
// if (bindingData.BindingExpression != null
// && bindingData.BindingExpression.ParentBinding != null
// && bindingData.BindingExpression.ParentBinding.UpdateSourceTrigger != UpdateSourceTrigger.Explicit)
// {
// Binding binding = ValidationUtil.CloneBinding(bindingData.BindingExpression.ParentBinding);
// if (binding != null)
// {
// binding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
// bindingData.Element.SetBinding(bindingData.BindingTarget, binding);
// bindingData.BindingExpression = bindingData.Element.GetBindingExpression(bindingData.BindingTarget);
// }
// }
// }
//}
return _editingElement;
}
@ -1027,8 +998,6 @@ namespace Avalonia.Controls
internal void RemoveEditingElement()
{
_editingElement = null;
//_inputBindings = null;
//_bindingPaths = null;
}
/// <summary>
@ -1078,157 +1047,12 @@ namespace Avalonia.Controls
}
}
/*
/// <summary>
/// Represents a <see cref="T:Avalonia.Controls.DataGrid" /> column.
/// </summary>
/// <QualityBand>Mature</QualityBand>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1036:OverrideMethodsOnComparableTypes", Justification = "IComparable in Jolt has only one method, probably a false positive in FxCop.")]
[StyleTypedProperty(Property = "CellStyle", StyleTargetType = typeof(DataGridCell))]
[StyleTypedProperty(Property = "DragIndicatorStyle", StyleTargetType = typeof(ContentControl))]
[StyleTypedProperty(Property = "HeaderStyle", StyleTargetType = typeof(DataGridColumnHeader))]
public abstract class DataGridColumn : AvaloniaObject
*/
#region Styles
//TODO Styles
/// <summary>
/// Gets or sets the style that is used when rendering cells in the column.
/// </summary>
/// <returns>
/// The style that is used when rendering cells in the column. The default is null.
/// </returns>
/*public Style CellStyle
{
get
{
return _cellStyle;
}
set
{
if (_cellStyle != value)
{
Style previousStyle = _cellStyle;
_cellStyle = value;
if (OwningGrid != null)
{
OwningGrid.OnColumnCellStyleChanged(this, previousStyle);
}
}
}
} */
/*public Style DragIndicatorStyle
{
get
{
return _dragIndicatorStyle;
}
set
{
if (_dragIndicatorStyle != value)
{
_dragIndicatorStyle = value;
}
}
} */
/*public Style HeaderStyle
{
get
{
return _headerStyle;
}
set
{
if (_headerStyle != value)
{
Style previousStyle = _headerStyle;
_headerStyle = value;
if (_headerCell != null)
{
_headerCell.EnsureStyle(previousStyle);
}
}
}
} */
#endregion
#region Binding
//TODO Binding
/*internal List<string> BindingPaths
{
get
{
if (_bindingPaths != null)
{
return _bindingPaths;
}
_bindingPaths = CreateBindingPaths();
return _bindingPaths;
}
} */
/*internal virtual List<string> CreateBindingPaths()
{
List<string> bindingPaths = new List<string>();
List<BindingInfo> bindings = null;
if (_inputBindings == null && OwningGrid != null)
{
DataGridRow row = OwningGrid.EditingRow;
if (row != null && row.Cells != null && row.Cells.Count > Index)
{
// Finds the input bindings if they don't already exist
GenerateEditingElementInternal(row.Cells[Index], row.DataContext);
}
}
if (_inputBindings != null)
{
Debug.Assert(OwningGrid != null);
// Use the editing bindings if they've already been created
bindings = _inputBindings;
}
if (bindings != null)
{
// We're going to return the path of every active binding
foreach (BindingInfo binding in bindings)
{
if (binding != null &&
binding.BindingExpression != null &&
binding.BindingExpression.ParentBinding != null &&
binding.BindingExpression.ParentBinding.Path != null)
{
bindingPaths.Add(binding.BindingExpression.ParentBinding.Path.Path);
}
}
}
return bindingPaths;
} */
/*internal virtual List<BindingInfo> CreateBindings(FrameworkElement element, object dataItem, bool twoWay)
{
//TODO: Binding ParameterNames
return element.GetBindingInfo(dataItem, twoWay, false, true, typeof(DataGrid));
} */
/*internal List<BindingInfo> GetInputBindings(FrameworkElement element, object dataItem)
{
if (_inputBindings != null)
{
return _inputBindings;
}
//TODO: Binding ParameterNames
return CreateBindings(element, dataItem, true);
} */
#endregion
}
}

1
src/Avalonia.Controls.DataGrid/DataGridColumnCollection.cs

@ -597,6 +597,5 @@ namespace Avalonia.Controls
}
#endregion Private Methods
}
}

220
src/Avalonia.Controls.DataGrid/DataGridColumnHeader.cs

@ -70,8 +70,6 @@ namespace Avalonia.Controls
AreSeparatorsVisibleProperty.Changed.AddClassHandler<DataGridColumnHeader>(x => x.OnAreSeparatorsVisibleChanged);
}
/// <summary>
/// Initializes a new instance of the <see cref="T:Avalonia.Controls.Primitives.DataGridColumnHeader" /> class.
/// </summary>
@ -84,49 +82,9 @@ namespace Avalonia.Controls
PointerEnter += DataGridColumnHeader_PointerEnter;
PointerLeave += DataGridColumnHeader_PointerLeave;
}
/*public DataGridColumnHeader()
{
LostMouseCapture += new MouseEventHandler(DataGridColumnHeader_LostMouseCapture);
MouseLeftButtonDown += new MouseButtonEventHandler(DataGridColumnHeader_MouseLeftButtonDown);
MouseLeftButtonUp += new MouseButtonEventHandler(DataGridColumnHeader_MouseLeftButtonUp);
MouseMove += new MouseEventHandler(DataGridColumnHeader_MouseMove);
MouseEnter += new MouseEventHandler(DataGridColumnHeader_MouseEnter);
MouseLeave += new MouseEventHandler(DataGridColumnHeader_MouseLeave);
DefaultStyleKey = typeof(DataGridColumnHeader);
} */
#region Protected Methods
/// <summary>
/// Builds the visual tree for the column header when a new template is applied.
/// </summary>
//TODO Implement
/*public override void OnApplyTemplate()
{
base.OnApplyTemplate();
ApplyState(false);
} */
/// <summary>
/// Called when the value of the <see cref="P:Avalonia.Controls.ContentControl.Content" /> property changes.
/// </summary>
/// <param name="oldContent">The old value of the <see cref="P:Avalonia.Controls.ContentControl.Content" /> property.</param>
/// <param name="newContent">The new value of the <see cref="P:Avalonia.Controls.ContentControl.Content" /> property.</param>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="newContent" /> is not a UIElement.
/// </exception>
//TODO Implement
/*protected override void OnContentChanged(object oldContent, object newContent)
{
if (newContent is UIElement)
{
throw DataGridError.DataGridColumnHeader.ContentDoesNotSupportUIElements();
}
base.OnContentChanged(oldContent, newContent);
} */
#endregion Protected Methods
private void OnAreSeparatorsVisibleChanged(AvaloniaPropertyChangedEventArgs e)
@ -208,48 +166,6 @@ namespace Avalonia.Controls
//TODO Implement
internal void ApplyState()
{
/*
// Common States
if (IsPressed && DataGridColumnHeader._dragMode != DragMode.Resize)
{
VisualStates.GoToState(this, useTransitions, VisualStates.StatePressed, VisualStates.StateMouseOver, VisualStates.StateNormal);
}
else if (IsMouseOver && DataGridColumnHeader._dragMode != DragMode.Resize)
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateMouseOver, VisualStates.StateNormal);
}
else
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateNormal);
}
// Sort States
CurrentSortingState = null;
if (OwningGrid != null
&& OwningGrid.DataConnection != null
&& OwningGrid.DataConnection.AllowSort)
{
SortDescription? sort = OwningColumn.GetSortDescription();
if (sort.HasValue)
{
CurrentSortingState = sort.Value.Direction;
if (CurrentSortingState == ListSortDirection.Ascending)
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateSortAscending, VisualStates.StateUnsorted);
}
if (CurrentSortingState == ListSortDirection.Descending)
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateSortDescending, VisualStates.StateUnsorted);
}
}
else
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateUnsorted);
}
}
*/
CurrentSortingState = null;
if (OwningGrid != null
&& OwningGrid.DataConnection != null
@ -267,18 +183,6 @@ namespace Avalonia.Controls
CurrentSortingState.HasValue && CurrentSortingState.Value == ListSortDirection.Descending);
}
//protected override void OnPointerReleased(PointerReleasedEventArgs e)
//{
// base.OnPointerReleased(e);
// bool handled = e.Handled;
// if (e.MouseButton == MouseButton.Left)
// {
// OnMouseLeftButtonUp_Click(e.InputModifiers, ref handled);
// e.Handled = handled;
// }
//}
internal void UpdateSeparatorVisibility(DataGridColumn lastVisibleColumn)
{
bool newVisibility = _desiredSeparatorVisibility;
@ -353,26 +257,6 @@ namespace Avalonia.Controls
// if shift is held down, we multi-sort, therefore if it isn't, we'll clear the sorts beforehand
if (!shift || owningGrid.DataConnection.SortDescriptions.Count == 0)
{
/*if (collectionView.CanGroup && collectionView.GroupDescriptions != null)
{
// Make sure we sort by the GroupDescriptions first
for (int i = 0; i < collectionView.GroupDescriptions.Count; i++)
{
PropertyGroupDescription groupDescription = collectionView.GroupDescriptions[i] as PropertyGroupDescription;
if (groupDescription != null && collectionView.SortDescriptions.Count <= i || collectionView.SortDescriptions[i].PropertyName != groupDescription.PropertyName)
{
collectionView.SortDescriptions.Insert(Math.Min(i, collectionView.SortDescriptions.Count), new SortDescription(groupDescription.PropertyName, ListSortDirection.Ascending));
}
}
while (collectionView.SortDescriptions.Count > collectionView.GroupDescriptions.Count)
{
collectionView.SortDescriptions.RemoveAt(collectionView.GroupDescriptions.Count);
}
}
else if (!shift)
{
owningGrid.DataConnection.SortDescriptions.Clear();
}*/
owningGrid.DataConnection.SortDescriptions.Clear();
}
@ -406,22 +290,10 @@ namespace Avalonia.Controls
owningGrid.DataConnection.SortDescriptions.Add(newSort);
}
}
// We've completed the sort, so send the Invoked event for the column header's automation peer
/*if (AutomationPeer.ListenerExists(AutomationEvents.InvokePatternOnInvoked))
{
AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(this);
if (peer != null)
{
peer.RaiseAutomationEvent(AutomationEvents.InvokePatternOnInvoked);
}
}*/
}
}
#endregion Internal Methods
#region Private Methods
private bool CanReorderColumn(DataGridColumn column)
@ -449,8 +321,6 @@ namespace Avalonia.Controls
return column.ActualCanUserResize;
}
private static bool TrySetResizeColumn(DataGridColumn column)
{
// If datagrid.CanUserResizeColumns == false, then the column can still override it
@ -537,15 +407,7 @@ namespace Avalonia.Controls
DataGridColumnEventArgs ea = new DataGridColumnEventArgs(OwningColumn);
OwningGrid.OnColumnReordered(ea);
}
//DragCompletedEventArgs dragCompletedEventArgs = new DragCompletedEventArgs(mousePosition.X - _dragStart.Value.X, mousePosition.Y - _dragStart.Value.Y, false);
//OwningGrid.OnColumnHeaderDragCompleted(dragCompletedEventArgs);
}
//else if (_dragMode == DragMode.Drag)
//{
// DragCompletedEventArgs dragCompletedEventArgs = new DragCompletedEventArgs(0, 0, false);
// OwningGrid.OnColumnHeaderDragCompleted(dragCompletedEventArgs);
//}
SetDragCursor(mousePosition);
@ -582,22 +444,11 @@ namespace Avalonia.Controls
_dragMode = DragMode.Drag;
}
//if (_dragMode == DragMode.Drag)
//{
// DragDeltaEventArgs dragDeltaEventArgs = new DragDeltaEventArgs(mousePositionHeaders.X - _lastMousePositionHeaders.Value.X, mousePositionHeaders.Y - _lastMousePositionHeaders.Value.Y);
// OwningGrid.OnColumnHeaderDragDelta(dragDeltaEventArgs);
//}
_lastMousePositionHeaders = mousePositionHeaders;
SetDragCursor(mousePosition);
}
/*private void DataGridColumnHeader_LostMouseCapture(object sender, MouseEventArgs e)
{
OnLostMouseCapture();
} */
private void DataGridColumnHeader_PointerEnter(object sender, PointerEventArgs e)
{
if (!IsEnabled)
@ -824,17 +675,7 @@ namespace Avalonia.Controls
dragIndicator.PseudoClasses.Add(":dragIndicator");
IControl dropLocationIndicator = OwningGrid.DropLocationIndicatorTemplate?.Build();
//dropLocationIndicator.SetStyleWithType(OwningGrid.DropLocationIndicatorStyle);
//if (OwningColumn.DragIndicatorStyle != null)
//{
// dragIndicator.SetStyleWithType(OwningColumn.DragIndicatorStyle);
//}
//else if (OwningGrid.DragIndicatorStyle != null)
//{
// dragIndicator.SetStyleWithType(OwningGrid.DragIndicatorStyle);
//}
// If the user didn't style the dropLocationIndicator's Height, default to the column header's height
if (dropLocationIndicator != null && double.IsNaN(dropLocationIndicator.Height) && dropLocationIndicator is Control element)
{
@ -881,9 +722,6 @@ namespace Avalonia.Controls
//handle entry into reorder mode
if (_dragMode == DragMode.MouseDown && _dragColumn == null && (distanceFromRight > DATAGRIDCOLUMNHEADER_resizeRegionWidth && distanceFromLeft > DATAGRIDCOLUMNHEADER_resizeRegionWidth))
{
//DragStartedEventArgs dragStartedEventArgs = new DragStartedEventArgs(mousePositionHeaders.X - _lastMousePositionHeaders.Value.X, mousePositionHeaders.Y - _lastMousePositionHeaders.Value.Y);
//OwningGrid.OnColumnHeaderDragStarted(dragStartedEventArgs);
handled = CanReorderColumn(OwningColumn);
if (handled)
@ -895,9 +733,6 @@ namespace Avalonia.Controls
//handle reorder mode (eg, positioning of the popup)
if (_dragMode == DragMode.Reorder && OwningGrid.ColumnHeaders.DragIndicator != null)
{
//DragDeltaEventArgs dragDeltaEventArgs = new DragDeltaEventArgs(mousePositionHeaders.X - _lastMousePositionHeaders.Value.X, mousePositionHeaders.Y - _lastMousePositionHeaders.Value.Y);
//OwningGrid.OnColumnHeaderDragDelta(dragDeltaEventArgs);
// Find header we're hovering over
DataGridColumn targetColumn = GetReorderingTargetColumn(mousePositionHeaders, !OwningColumn.IsFrozen /*scroll*/, out double scrollAmount);
@ -994,58 +829,5 @@ namespace Avalonia.Controls
#region Style
//TODO Styles
/// <summary>
/// Ensures that the correct Style is applied to this object.
/// </summary>
/// <param name="previousStyle">Caller's previous associated Style</param>
/*internal void EnsureStyle(Style previousStyle)
{
if (Style != null
&& (OwningColumn == null || Style != OwningColumn.HeaderStyle)
&& (OwningGrid == null || Style != OwningGrid.ColumnHeaderStyle)
&& (Style != previousStyle))
{
return;
}
Style style = null;
if (OwningColumn != null)
{
style = OwningColumn.HeaderStyle;
}
if (style == null && OwningGrid != null)
{
style = OwningGrid.ColumnHeaderStyle;
}
SetStyleWithType(style);
} */
#endregion
/*
/// <QualityBand>Mature</QualityBand>
[TemplateVisualState(Name = VisualStates.StateNormal, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = VisualStates.StateMouseOver, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = VisualStates.StatePressed, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = VisualStates.StateUnsorted, GroupName = VisualStates.GroupSort)]
[TemplateVisualState(Name = VisualStates.StateSortAscending, GroupName = VisualStates.GroupSort)]
[TemplateVisualState(Name = VisualStates.StateSortDescending, GroupName = VisualStates.GroupSort)]
public partial class DataGridColumnHeader : ContentControl
*/
/// <summary>
/// Creates AutomationPeer (<see cref="UIElement.OnCreateAutomationPeer"/>)
/// </summary>
/*protected override AutomationPeer OnCreateAutomationPeer()
{
if (OwningGrid != null && OwningColumn != OwningGrid.ColumnsInternal.FillerColumn)
{
return new DataGridColumnHeaderAutomationPeer(this);
}
return base.OnCreateAutomationPeer();
} */
}

52
src/Avalonia.Controls.DataGrid/DataGridColumns.cs

@ -1778,61 +1778,9 @@ namespace Avalonia.Controls
#region DragDrop
//TODO DragDrop
/*internal void OnColumnHeaderDragStarted(DragStartedEventArgs e)
{
if (ColumnHeaderDragStarted != null)
{
ColumnHeaderDragStarted(this, e);
}
}*/
/*internal void OnColumnHeaderDragDelta(DragDeltaEventArgs e)
{
if (ColumnHeaderDragDelta != null)
{
ColumnHeaderDragDelta(this, e);
}
}*/
/*internal void OnColumnHeaderDragCompleted(DragCompletedEventArgs e)
{
if (ColumnHeaderDragCompleted != null)
{
ColumnHeaderDragCompleted(this, e);
}
}*/
#endregion
#region Styles
//TODO Styles
/*internal void OnColumnElementStyleChanged(DataGridBoundColumn column)
{
// Update Element Style in Displayed rows
foreach (DataGridRow row in GetAllRows())
{
Control element = column.GetCellContent(row);
if (element != null)
{
element.SetStyleWithType(column.ElementStyle);
}
}
InvalidateRowHeightEstimate();
}*/
/*internal void OnColumnCellStyleChanged(DataGridColumn column, Style previousStyle)
{
// Set HeaderCell.Style for displayed rows if HeaderCell.Style is not already set
foreach (DataGridRow row in GetAllRows())
{
row.Cells[column.Index].EnsureStyle(previousStyle);
}
InvalidateRowHeightEstimate();
}*/
#endregion
}

12
src/Avalonia.Controls.DataGrid/DataGridDataConnection.cs

@ -33,14 +33,6 @@ namespace Avalonia.Controls
private bool _scrollForCurrentChanged;
private DataGridSelectionAction _selectionActionForCurrentChanged;
/*
//TODO Check
private WeakEventListener<DataGridDataConnection, object, NotifyCollectionChangedEventArgs> _weakCollectionChangedListener;
private WeakEventListener<DataGridDataConnection, object, NotifyCollectionChangedEventArgs> _weakSortDescriptionsCollectionChangedListener;
private WeakEventListener<DataGridDataConnection, object, CurrentChangingEventArgs> _weakCurrentChangingListener;
private WeakEventListener<DataGridDataConnection, object, EventArgs> _weakCurrentChangedListener;
*/
#endregion Data
public DataGridDataConnection(DataGrid owner)
@ -190,9 +182,6 @@ namespace Avalonia.Controls
get
{
return false;
//return _owner.AutoGenerateColumns
// && (_owner.ColumnsInternal.AutogeneratedColumnCount == 0)
// && ((DataProperties != null && DataProperties.Length > 0) || DataIsPrimitive);
}
}
@ -556,7 +545,6 @@ namespace Avalonia.Controls
if (CollectionView != null)
{
//Avalonia.Utilities.WeakSubscriptionManager.Subscribe(CollectionView, "CurrentChanged", CollectionView_CurrentChanged);
CollectionView.CurrentChanged += CollectionView_CurrentChanged;
CollectionView.CurrentChanging += CollectionView_CurrentChanging;
}

11
src/Avalonia.Controls.DataGrid/DataGridError.cs

@ -124,15 +124,6 @@ namespace Avalonia.Controls
}
//
public static class DataGridColumnHeader
{
public static NotSupportedException ContentDoesNotSupportUIElements()
@ -196,4 +187,4 @@ namespace Avalonia.Controls
return String.Format(CultureInfo.CurrentCulture, formatString, args);
}
}
}
}

1
src/Avalonia.Controls.DataGrid/DataGridFillerColumn.cs

@ -11,7 +11,6 @@ namespace Avalonia.Controls
{
internal class DataGridFillerColumn : DataGridColumn
{
public DataGridFillerColumn(DataGrid owningGrid)
{
IsReadOnly = true;

1
src/Avalonia.Controls.DataGrid/DataGridLength.cs

@ -43,7 +43,6 @@ namespace Avalonia.Controls
#endregion Data
#region Constructors
/// <summary>

373
src/Avalonia.Controls.DataGrid/DataGridRow.cs

@ -36,13 +36,6 @@ namespace Avalonia.Controls
#endregion
/*
private bool _animatingDetails;
private Storyboard _detailsVisibleStoryboard;
private DoubleAnimation _detailsHeightAnimation;
private double? _detailsHeightAnimationToOverride;
*/
#region Fields
@ -55,20 +48,23 @@ namespace Avalonia.Controls
private Rectangle _bottomGridLine;
private bool _areHandlersSuspended;
// In the case where Details scales vertically when it's arranged at a different width, we
// get the wrong height measurement so we need to check it again after arrange
private bool _checkDetailsContentHeight;
// Optimal height of the details based on the Element created by the DataTemplate
private double _detailsDesiredHeight;
private bool _detailsLoaded;
private bool _detailsVisibilityNotificationPending;
private IControl _detailsContent;
private IDisposable _detailsContentSizeSubscription;
private DataGridDetailsPresenter _detailsElement;
// Locally cache whether or not details are visible so we don't run redundant storyboards
// The Details Template that is actually applied to the Row
private IDataTemplate _appliedDetailsTemplate;
private bool? _appliedDetailsVisibility;
#endregion
@ -104,7 +100,6 @@ namespace Avalonia.Controls
internal set { SetAndRaise(IsValidProperty, ref _isValid, value); }
}
public static readonly StyledProperty<IDataTemplate> DetailsTemplateProperty =
AvaloniaProperty.Register<DataGridRow, IDataTemplate>(nameof(DetailsTemplate));
@ -117,7 +112,6 @@ namespace Avalonia.Controls
set { SetValue(DetailsTemplateProperty, value); }
}
public static readonly StyledProperty<bool> AreDetailsVisibleProperty =
AvaloniaProperty.Register<DataGridRow, bool>(nameof(AreDetailsVisible));
@ -132,13 +126,11 @@ namespace Avalonia.Controls
#endregion
static DataGridRow()
{
HeaderProperty.Changed.AddClassHandler<DataGridRow>(x => x.OnHeaderChanged);
DetailsTemplateProperty.Changed.AddClassHandler<DataGridRow>(x => x.OnDetailsTemplateChanged);
AreDetailsVisibleProperty.Changed.AddClassHandler<DataGridRow>(x => x.OnAreDetailsVisibleChanged);
PointerPressedEvent.AddClassHandler<DataGridRow>(x => x.DataGridRow_PointerPressed, handledEventsToo: true);
}
@ -673,70 +665,6 @@ namespace Avalonia.Controls
PseudoClasses.Set(":editing", IsEditing);
if (RootElement != null && OwningGrid != null && IsVisible)
{
//Debug.Assert(Index != -1);
//byte idealStateMappingIndex = 0;
//if (IsSelected || IsEditing)
//{
// idealStateMappingIndex += 8;
//}
//if (IsEditing)
//{
// idealStateMappingIndex += 4;
//}
//if (IsMouseOver)
//{
// idealStateMappingIndex += 2;
//}
//if (OwningGrid.ContainsFocus)
//{
// idealStateMappingIndex += 1;
//}
//byte stateCode = _idealStateMapping[idealStateMappingIndex];
//Debug.Assert(stateCode != DATAGRIDROW_stateNullCode);
//string storyboardName;
//string legacyStoryboardName;
//while (stateCode != DATAGRIDROW_stateNullCode)
//{
// if (stateCode == DATAGRIDROW_stateNormalCode)
// {
// if (Index % 2 == 1)
// {
// storyboardName = DATAGRIDROW_stateAlternate;
// legacyStoryboardName = DATAGRIDROW_stateAlternateLegacy;
// }
// else
// {
// storyboardName = DATAGRIDROW_stateNormal;
// legacyStoryboardName = DATAGRIDROW_stateNormal;
// }
// }
// else
// {
// storyboardName = _stateNames[stateCode];
// legacyStoryboardName = _legacyStateNames[stateCode];
// }
// if (VisualStateManager.GoToState(this, storyboardName, animate) || VisualStateManager.GoToState(this, legacyStoryboardName, animate))
// {
// break;
// }
// else
// {
// // The state wasn't implemented so fall back to the next one
// stateCode = _fallbackStateMapping[stateCode];
// }
//}
//if (IsValid)
//{
// VisualStates.GoToState(this, animate, VisualStates.StateValid);
//}
//else
//{
// VisualStates.GoToState(this, animate, VisualStates.StateInvalid, VisualStates.StateValid);
//}
ApplyHeaderStatus();
}
}
@ -765,8 +693,6 @@ namespace Avalonia.Controls
}
}
//StopDetailsAnimation();
Slot = -1;
}
@ -848,16 +774,6 @@ namespace Avalonia.Controls
if (_headerElement != null && OwningGrid != null)
{
_headerElement.IsVisible = OwningGrid.AreRowHeadersVisible;
//if (OwningGrid.AreRowHeadersVisible)
//{
// _headerElement.EnsureStyle(previousStyle);
// _headerElement.Visibility = Visibility.Visible;
//}
//else
//{
// _headerElement.Visibility = Visibility.Collapsed;
//}
}
}
@ -960,31 +876,6 @@ namespace Avalonia.Controls
}
}
/*private Storyboard DetailsVisibleStoryboard
{
get
{
if (_detailsVisibleStoryboard == null && RootElement != null)
{
_detailsVisibleStoryboard = RootElement.Resources[DATAGRIDROW_detailsVisibleTransition] as Storyboard;
if (_detailsVisibleStoryboard != null)
{
_detailsVisibleStoryboard.Completed += new EventHandler(DetailsVisibleStoryboard_Completed);
if (_detailsVisibleStoryboard.Children.Count > 0)
{
// If the user set a To value for the animation, we want to respect
_detailsHeightAnimation = _detailsVisibleStoryboard.Children[0] as DoubleAnimation;
if (_detailsHeightAnimation != null)
{
_detailsHeightAnimationToOverride = _detailsHeightAnimation.To;
}
}
}
}
return _detailsVisibleStoryboard;
}
} */
private void UnloadDetailsTemplate(bool recycle)
{
if (_detailsElement != null)
@ -1021,15 +912,6 @@ namespace Avalonia.Controls
SetValueNoCallback(AreDetailsVisibleProperty, false);
}
/*private void StopDetailsAnimation()
{
if (DetailsVisibleStoryboard != null)
{
DetailsVisibleStoryboard.Stop();
_animatingDetails = false;
}
} */
//TODO Animation
internal void EnsureDetailsContentHeight()
{
@ -1042,7 +924,7 @@ namespace Avalonia.Controls
&& Slot != -1)
{
_detailsDesiredHeight = _detailsContent.Bounds.Height;
//if (!_animatingDetails)
if (true)
{
_detailsElement.ContentHeight = _detailsDesiredHeight;
@ -1087,22 +969,12 @@ namespace Avalonia.Controls
// Update the new desired height for RowDetails
_detailsDesiredHeight = newValue.Height;
//if (DetailsVisibleStoryboard != null)
//{
// DetailsVisibleStoryboard.SkipToFill();
// StopDetailsAnimation();
//}
_detailsElement.ContentHeight = newValue.Height;
// Calling this when details are not visible invalidates during layout when we have no work
// to do. In certain scenarios, this could cause a layout cycle
OnRowDetailsChanged();
}
//else if(_detailsContent != null)
//{
// _detailsDesiredHeight = _detailsContent.DesiredSize.Height;
//}
}
}
else
@ -1111,23 +983,6 @@ namespace Avalonia.Controls
}
}
/*private void DetailsVisibleStoryboard_Completed(object sender, EventArgs e)
{
_animatingDetails = false;
if (OwningGrid != null && (Slot != -1) && OwningGrid.IsSlotVisible(Slot))
{
if (AreDetailsVisible)
{
Debug.Assert(!double.IsNaN(_detailsDesiredHeight));
Debug.Assert(_detailsContent != null);
// The height of the DetailsContents may have changed while we were animating its height
_detailsElement.ContentHeight = _detailsDesiredHeight;
}
OwningGrid.OnRowDetailsChanged();
}
} */
//TODO Animation
// Sets AreDetailsVisible on the row and animates if necessary
internal void SetDetailsVisibilityInternal(bool isVisible, bool raiseNotification, bool animate)
@ -1149,8 +1004,6 @@ namespace Avalonia.Controls
_appliedDetailsVisibility = isVisible;
SetValueNoCallback(AreDetailsVisibleProperty, isVisible);
//StopDetailsAnimation();
// Applies a new DetailsTemplate only if it has changed either here or at the DataGrid level
ApplyDetailsTemplate(initializeDetailsPreferredHeight: true);
@ -1164,42 +1017,17 @@ namespace Avalonia.Controls
return;
}
if(false)
{ }
//if (animate && DetailsVisibleStoryboard != null && _detailsHeightAnimation != null)
//{
// if (AreDetailsVisible)
// {
// // Expand
// _detailsHeightAnimation.From = 0.0;
// _detailsHeightAnimation.To = _detailsHeightAnimationToOverride.HasValue ?
// _detailsHeightAnimationToOverride.Value :
// _detailsDesiredHeight;
// _checkDetailsContentHeight = true;
// }
// else
// {
// // Collapse
// _detailsHeightAnimation.From = _detailsElement.ActualHeight;
// _detailsHeightAnimation.To = 0.0;
// }
// _animatingDetails = true;
// DetailsVisibleStoryboard.Begin();
//}
if (AreDetailsVisible)
{
// Set the details height directly
_detailsElement.ContentHeight = _detailsDesiredHeight;
_checkDetailsContentHeight = true;
}
else
{
if (AreDetailsVisible)
{
// Set the details height directly
_detailsElement.ContentHeight = _detailsDesiredHeight;
_checkDetailsContentHeight = true;
}
else
{
_detailsElement.ContentHeight = 0;
}
_detailsElement.ContentHeight = 0;
}
OnRowDetailsChanged();
if (raiseNotification)
@ -1258,192 +1086,21 @@ namespace Avalonia.Controls
_detailsElement.ContentHeight = _detailsDesiredHeight;
}
}
}
}
#endregion
}
/*
[TemplatePart(Name = DATAGRIDROW_elementBottomGridLine, Type = typeof(Rectangle))]
[TemplatePart(Name = DATAGRIDROW_elementCells, Type = typeof(DataGridCellsPresenter))]
[TemplatePart(Name = DATAGRIDROW_elementDetails, Type = typeof(DataGridDetailsPresenter))]
[TemplatePart(Name = DATAGRIDROW_elementRoot, Type = typeof(Panel))]
[TemplatePart(Name = DATAGRIDROW_elementRowHeader, Type = typeof(DataGridRowHeader))]
[TemplateVisualState(Name = DATAGRIDROW_stateNormal, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROW_stateAlternate, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROW_stateNormalEditing, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROW_stateNormalEditingFocused, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROW_stateSelected, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROW_stateSelectedFocused, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROW_stateMouseOver, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROW_stateMouseOverEditing, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROW_stateMouseOverEditingFocused, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROW_stateMouseOverSelected, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROW_stateMouseOverSelectedFocused, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = VisualStates.StateInvalid, GroupName = VisualStates.GroupValidation)]
[TemplateVisualState(Name = VisualStates.StateValid, GroupName = VisualStates.GroupValidation)]
[StyleTypedProperty(Property = "HeaderStyle", StyleTargetType = typeof(DataGridRowHeader))]
public partial class DataGridRow : Control
*/
#region Constants
/*
private const string DATAGRIDROW_detailsVisibleTransition = "DetailsVisibleTransition";
private const string DATAGRIDROW_stateAlternate = "NormalAlternatingRow";
private const string DATAGRIDROW_stateAlternateLegacy = "Normal AlternatingRow";
private const string DATAGRIDROW_stateMouseOver = "MouseOver";
private const string DATAGRIDROW_stateMouseOverEditing = "MouseOverUnfocusedEditing";
private const string DATAGRIDROW_stateMouseOverEditingLegacy = "MouseOver Unfocused Editing";
private const string DATAGRIDROW_stateMouseOverEditingFocused = "MouseOverEditing";
private const string DATAGRIDROW_stateMouseOverEditingFocusedLegacy = "MouseOver Editing";
private const string DATAGRIDROW_stateMouseOverSelected = "MouseOverUnfocusedSelected";
private const string DATAGRIDROW_stateMouseOverSelectedLegacy = "MouseOver Unfocused Selected";
private const string DATAGRIDROW_stateMouseOverSelectedFocused = "MouseOverSelected";
private const string DATAGRIDROW_stateMouseOverSelectedFocusedLegacy = "MouseOver Selected";
private const string DATAGRIDROW_stateNormal = "Normal";
private const string DATAGRIDROW_stateNormalEditing = "UnfocusedEditing";
private const string DATAGRIDROW_stateNormalEditingLegacy = "Unfocused Editing";
private const string DATAGRIDROW_stateNormalEditingFocused = "NormalEditing";
private const string DATAGRIDROW_stateNormalEditingFocusedLegacy = "Normal Editing";
private const string DATAGRIDROW_stateSelected = "UnfocusedSelected";
private const string DATAGRIDROW_stateSelectedLegacy = "Unfocused Selected";
private const string DATAGRIDROW_stateSelectedFocused = "NormalSelected";
private const string DATAGRIDROW_stateSelectedFocusedLegacy = "Normal Selected";
private const byte DATAGRIDROW_stateMouseOverCode = 0;
private const byte DATAGRIDROW_stateMouseOverEditingCode = 1;
private const byte DATAGRIDROW_stateMouseOverEditingFocusedCode = 2;
private const byte DATAGRIDROW_stateMouseOverSelectedCode = 3;
private const byte DATAGRIDROW_stateMouseOverSelectedFocusedCode = 4;
private const byte DATAGRIDROW_stateNormalCode = 5;
private const byte DATAGRIDROW_stateNormalEditingCode = 6;
private const byte DATAGRIDROW_stateNormalEditingFocusedCode = 7;
private const byte DATAGRIDROW_stateSelectedCode = 8;
private const byte DATAGRIDROW_stateSelectedFocusedCode = 9;
private const byte DATAGRIDROW_stateNullCode = 255;
*/
#endregion Constants
#region Data
// Static arrays to handle state transitions:
/*private static byte[] _idealStateMapping = new byte[] {
DATAGRIDROW_stateNormalCode,
DATAGRIDROW_stateNormalCode,
DATAGRIDROW_stateMouseOverCode,
DATAGRIDROW_stateMouseOverCode,
DATAGRIDROW_stateNullCode,
DATAGRIDROW_stateNullCode,
DATAGRIDROW_stateNullCode,
DATAGRIDROW_stateNullCode,
DATAGRIDROW_stateSelectedCode,
DATAGRIDROW_stateSelectedFocusedCode,
DATAGRIDROW_stateMouseOverSelectedCode,
DATAGRIDROW_stateMouseOverSelectedFocusedCode,
DATAGRIDROW_stateNormalEditingCode,
DATAGRIDROW_stateNormalEditingFocusedCode,
DATAGRIDROW_stateMouseOverEditingCode,
DATAGRIDROW_stateMouseOverEditingFocusedCode
}; */
/*private static byte[] _fallbackStateMapping = new byte[] {
DATAGRIDROW_stateNormalCode, //DATAGRIDROW_stateMouseOverCode's fallback
DATAGRIDROW_stateMouseOverEditingFocusedCode, //DATAGRIDROW_stateMouseOverEditingCode's fallback
DATAGRIDROW_stateNormalEditingFocusedCode, //DATAGRIDROW_stateMouseOverEditingFocusedCode's fallback
DATAGRIDROW_stateMouseOverSelectedFocusedCode, //DATAGRIDROW_stateMouseOverSelectedCode's fallback
DATAGRIDROW_stateSelectedFocusedCode, //DATAGRIDROW_stateMouseOverSelectedFocusedCode's fallback
DATAGRIDROW_stateNullCode, //DATAGRIDROW_stateNormalCode's fallback
DATAGRIDROW_stateNormalEditingFocusedCode, //DATAGRIDROW_stateNormalEditingCode's fallback
DATAGRIDROW_stateSelectedFocusedCode, //DATAGRIDROW_stateNormalEditingFocusedCode's fallback
DATAGRIDROW_stateSelectedFocusedCode, //DATAGRIDROW_stateSelectedCode's fallback
DATAGRIDROW_stateNormalCode //DATAGRIDROW_stateSelectedFocusedCode's fallback
}; */
// In SL 2, our state names had spaces. Going forward, we are removing the spaces but still
// supporting the legacy state names
/*private static string[] _legacyStateNames = new string[] {
DATAGRIDROW_stateMouseOver,
DATAGRIDROW_stateMouseOverEditingLegacy,
DATAGRIDROW_stateMouseOverEditingFocusedLegacy,
DATAGRIDROW_stateMouseOverSelectedLegacy,
DATAGRIDROW_stateMouseOverSelectedFocusedLegacy,
DATAGRIDROW_stateNormal,
DATAGRIDROW_stateNormalEditingLegacy,
DATAGRIDROW_stateNormalEditingFocusedLegacy,
DATAGRIDROW_stateSelectedLegacy,
DATAGRIDROW_stateSelectedFocusedLegacy
}; */
/*private static string[] _stateNames = new string[] {
DATAGRIDROW_stateMouseOver,
DATAGRIDROW_stateMouseOverEditing,
DATAGRIDROW_stateMouseOverEditingFocused,
DATAGRIDROW_stateMouseOverSelected,
DATAGRIDROW_stateMouseOverSelectedFocused,
DATAGRIDROW_stateNormal,
DATAGRIDROW_stateNormalEditing,
DATAGRIDROW_stateNormalEditingFocused,
DATAGRIDROW_stateSelected,
DATAGRIDROW_stateSelectedFocused
}; */
#endregion Data
#region HeaderStyle
//TODO Styles
/// <summary>
/// Gets or sets the style that is used when rendering the row header.
/// </summary>
/*public Style HeaderStyle
{
get { return GetValue(HeaderStyleProperty) as Style; }
set { SetValue(HeaderStyleProperty, value); }
} */
/// <summary>
/// Identifies the <see cref="P:Avalonia.Controls.DataGridRow.HeaderStyle" /> dependency property.
/// </summary>
/*public static readonly DependencyProperty HeaderStyleProperty =
DependencyProperty.Register(
"HeaderStyle",
typeof(Style),
typeof(DataGridRow),
new PropertyMetadata(OnHeaderStylePropertyChanged));
/*private static void OnHeaderStylePropertyChanged(AvaloniaObject d, DependencyPropertyChangedEventArgs e)
{
DataGridRow row = d as DataGridRow;
if (row != null && row._headerElement != null)
{
row._headerElement.EnsureStyle(e.OldValue as Style);
}
} */
#endregion HeaderStyle
/// <summary>
/// Creates AutomationPeer (<see cref="UIElement.OnCreateAutomationPeer"/>)
/// </summary>
/*protected override AutomationPeer OnCreateAutomationPeer()
{
return new DataGridRowAutomationPeer(this);
} */
}
}

88
src/Avalonia.Controls.DataGrid/DataGridRowGroupHeader.cs

@ -28,7 +28,6 @@ namespace Avalonia.Controls
private Panel _rootElement;
private double _totalIndent;
public static readonly StyledProperty<bool> IsItemCountVisibleProperty =
AvaloniaProperty.Register<DataGridRowGroupHeader, bool>(nameof(IsItemCountVisible));
@ -41,7 +40,6 @@ namespace Avalonia.Controls
set { SetValue(IsItemCountVisibleProperty, value); }
}
public static readonly StyledProperty<string> PropertyNameProperty =
AvaloniaProperty.Register<DataGridRowGroupHeader, string>(nameof(PropertyName));
@ -54,7 +52,6 @@ namespace Avalonia.Controls
set { SetValue(PropertyNameProperty, value); }
}
public static readonly StyledProperty<bool> IsPropertyNameVisibleProperty =
AvaloniaProperty.Register<DataGridRowGroupHeader, bool>(nameof(IsPropertyNameVisible));
@ -67,7 +64,6 @@ namespace Avalonia.Controls
set { SetValue(IsPropertyNameVisibleProperty, value); }
}
public static readonly StyledProperty<double> SublevelIndentProperty =
AvaloniaProperty.Register<DataGridRowGroupHeader, double>(
nameof(SublevelIndent),
@ -238,43 +234,7 @@ namespace Avalonia.Controls
//TODO Implement
internal void ApplyState(bool useTransitions)
{
/*
// Common States
if (IsMouseOver)
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateMouseOver, VisualStates.StateNormal);
}
else
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateNormal);
}
// Current States
if (IsCurrent)
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateCurrent, VisualStates.StateRegular);
}
else
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateRegular);
}
// Expanded States
if (RowGroupInfo.CollectionViewGroup.ItemCount == 0)
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateEmpty);
}
else
{
if (RowGroupInfo.Visibility == Visibility.Visible)
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateExpanded, VisualStates.StateEmpty);
}
else
{
VisualStates.GoToState(this, useTransitions, VisualStates.StateCollapsed, VisualStates.StateEmpty);
}
}*/
}
protected override Size ArrangeOverride(Size finalSize)
@ -391,15 +351,6 @@ namespace Avalonia.Controls
if (_headerElement != null && OwningGrid != null)
{
_headerElement.IsVisible = OwningGrid.AreColumnHeadersVisible;
//if (OwningGrid.AreRowHeadersVisible)
//{
// _headerElement.EnsureStyle(previousStyle);
// ;
//}
//else
//{
// _headerElement.IsVisible = false;
//}
}
}
@ -414,8 +365,6 @@ namespace Avalonia.Controls
internal void LoadVisualsForDisplay()
{
EnsureExpanderButtonIsChecked();
//EnsureHeaderStyleAndVisibility(null);
EnsureHeaderVisibility();
ApplyState(useTransitions: false);
ApplyHeaderStatus();
@ -505,39 +454,4 @@ namespace Avalonia.Controls
#endregion Methods
}
/*
#region HeaderStyle
//TODO Styles
/// <summary>
/// The style applied to the header cell of a <see cref="T:Avalonia.Controls.DataGridRowGroupHeader" />.
/// </summary>
public Style HeaderStyle
{
get { return GetValue(HeaderStyleProperty) as Style; }
set { SetValue(HeaderStyleProperty, value); }
}
/// <summary>
/// Dependency Property for HeaderStyle
/// </summary>
public static readonly DependencyProperty HeaderStyleProperty =
DependencyProperty.Register(
"HeaderStyle",
typeof(Style),
typeof(DataGridRowGroupHeader),
new PropertyMetadata(OnHeaderStylePropertyChanged));
private static void OnHeaderStylePropertyChanged(AvaloniaObject d, DependencyPropertyChangedEventArgs e)
{
DataGridRowGroupHeader groupHeader = d as DataGridRowGroupHeader;
if (groupHeader._headerElement != null)
{
groupHeader._headerElement.EnsureStyle(e.OldValue as Style);
}
}
#endregion HeaderStyle
*/
}
}

283
src/Avalonia.Controls.DataGrid/DataGridRowHeader.cs

@ -25,7 +25,6 @@ namespace Avalonia.Controls.Primitives
#region Dependency Properties
public static readonly StyledProperty<IBrush> SeparatorBrushProperty =
AvaloniaProperty.Register<DataGridRowHeader, IBrush>(nameof(SeparatorBrush));
@ -35,7 +34,6 @@ namespace Avalonia.Controls.Primitives
set { SetValue(SeparatorBrushProperty, value); }
}
public static readonly StyledProperty<bool> AreSeparatorsVisibleProperty =
AvaloniaProperty.Register<DataGridRowHeader, bool>(
nameof(AreSeparatorsVisible));
@ -51,7 +49,6 @@ namespace Avalonia.Controls.Primitives
#endregion
/// <summary>
/// Initializes a new instance of the <see cref="T:Avalonia.Controls.Primitives.DataGridRowHeader" /> class.
/// </summary>
@ -62,7 +59,6 @@ namespace Avalonia.Controls.Primitives
#region Properties
internal Control Owner
{
get;
@ -153,7 +149,6 @@ namespace Avalonia.Controls.Primitives
#endregion Protected Methods
#region Internal Methods
//TODO Implement
@ -161,71 +156,12 @@ namespace Avalonia.Controls.Primitives
{
if (_rootElement != null && Owner != null && Owner.IsVisible)
{
//byte idealStateMappingIndex = 0;
//if (OwningRow != null)
//{
// if (OwningRow.IsValid)
// {
// VisualStates.GoToState(this, true, VisualStates.StateRowValid);
// }
// else
// {
// VisualStates.GoToState(this, true, VisualStates.StateRowInvalid, VisualStates.StateRowValid);
// }
// if (OwningGrid != null)
// {
// if (OwningGrid.CurrentSlot == OwningRow.Slot)
// {
// idealStateMappingIndex += 16;
// }
// if (OwningGrid.ContainsFocus)
// {
// idealStateMappingIndex += 1;
// }
// }
// if (OwningRow.IsSelected || OwningRow.IsEditing)
// {
// idealStateMappingIndex += 8;
// }
// if (OwningRow.IsEditing)
// {
// idealStateMappingIndex += 4;
// }
// if (OwningRow.IsMouseOver)
// {
// idealStateMappingIndex += 2;
// }
//}
//else if (OwningRowGroupHeader != null && OwningGrid != null && OwningGrid.CurrentSlot == OwningRowGroupHeader.RowGroupInfo.Slot)
//{
// idealStateMappingIndex += 16;
//}
//byte stateCode = _idealStateMapping[idealStateMappingIndex];
//Debug.Assert(stateCode != DATAGRIDROWHEADER_stateNullCode);
//string storyboardName;
//while (stateCode != DATAGRIDROWHEADER_stateNullCode)
//{
// storyboardName = _stateNames[stateCode];
// if (VisualStateManager.GoToState(this, storyboardName, animate) || VisualStateManager.GoToState(this, _legacyStateNames[stateCode], animate))
// {
// break;
// }
// else
// {
// // The state wasn't implemented so fall back to the next one
// stateCode = _fallbackStateMapping[stateCode];
// }
//}
}
}
#endregion Internal Methods
#region Private Methods
protected override void OnPointerEnter(PointerEventArgs e)
@ -276,227 +212,12 @@ namespace Avalonia.Controls.Primitives
}
/*
[TemplatePart(Name = DATAGRIDROWHEADER_elementRootName, Type = typeof(FrameworkElement))]
[TemplateVisualState(Name = DATAGRIDROWHEADER_stateNormal, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROWHEADER_stateNormalCurrentRow, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROWHEADER_stateNormalEditingRow, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROWHEADER_stateNormalEditingRowFocused, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROWHEADER_stateMouseOver, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROWHEADER_stateMouseOverCurrentRow, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROWHEADER_stateMouseOverEditingRow, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROWHEADER_stateMouseOverEditingRowFocused, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROWHEADER_stateMouseOverSelected, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROWHEADER_stateMouseOverSelectedFocused, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROWHEADER_stateMouseOverSelectedCurrentRow, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROWHEADER_stateMouseOverSelectedCurrentRowFocused, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROWHEADER_stateSelected, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROWHEADER_stateSelectedCurrentRow, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROWHEADER_stateSelectedCurrentRowFocused, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = DATAGRIDROWHEADER_stateSelectedFocused, GroupName = VisualStates.GroupCommon)]
[TemplateVisualState(Name = VisualStates.StateRowInvalid, GroupName = VisualStates.GroupValidation)]
[TemplateVisualState(Name = VisualStates.StateRowValid, GroupName = VisualStates.GroupValidation)]
public partial class DataGridRowHeader : ContentControl
*/
#region Styles
//TODO Styles
/// <summary>
/// Ensures that the correct Style is applied to this object.
/// </summary>
/// <param name="previousStyle">Caller's previous associated Style</param>
/*internal void EnsureStyle(Style previousStyle)
{
if (Style != null
&& (OwningRow != null && Style != OwningRow.HeaderStyle)
&& (OwningRowGroupHeader != null && Style != OwningRowGroupHeader.HeaderStyle)
&& (OwningGrid != null && Style != OwningGrid.RowHeaderStyle)
&& (Style != previousStyle))
{
return;
}
Style style = null;
if (OwningRow != null)
{
style = OwningRow.HeaderStyle;
}
if (style == null && OwningGrid != null)
{
style = OwningGrid.RowHeaderStyle;
}
SetStyleWithType(style);
} */
#endregion
#region Constants
/*
private const string DATAGRIDROWHEADER_stateMouseOver = "MouseOver";
private const string DATAGRIDROWHEADER_stateMouseOverCurrentRow = "MouseOverCurrentRow";
private const string DATAGRIDROWHEADER_stateMouseOverCurrentRowLegacy = "MouseOver CurrentRow";
private const string DATAGRIDROWHEADER_stateMouseOverEditingRow = "MouseOverUnfocusedEditingRow";
private const string DATAGRIDROWHEADER_stateMouseOverEditingRowLegacy = "MouseOver Unfocused EditingRow";
private const string DATAGRIDROWHEADER_stateMouseOverEditingRowFocused = "MouseOverEditingRow";
private const string DATAGRIDROWHEADER_stateMouseOverEditingRowFocusedLegacy = "MouseOver EditingRow";
private const string DATAGRIDROWHEADER_stateMouseOverSelected = "MouseOverUnfocusedSelected";
private const string DATAGRIDROWHEADER_stateMouseOverSelectedLegacy = "MouseOver Unfocused Selected";
private const string DATAGRIDROWHEADER_stateMouseOverSelectedCurrentRow = "MouseOverUnfocusedCurrentRowSelected";
private const string DATAGRIDROWHEADER_stateMouseOverSelectedCurrentRowLegacy = "MouseOver Unfocused CurrentRow Selected";
private const string DATAGRIDROWHEADER_stateMouseOverSelectedCurrentRowFocused = "MouseOverCurrentRowSelected";
private const string DATAGRIDROWHEADER_stateMouseOverSelectedCurrentRowFocusedLegacy = "MouseOver CurrentRow Selected";
private const string DATAGRIDROWHEADER_stateMouseOverSelectedFocused = "MouseOverSelected";
private const string DATAGRIDROWHEADER_stateMouseOverSelectedFocusedLegacy = "MouseOver Selected";
private const string DATAGRIDROWHEADER_stateNormal = "Normal";
private const string DATAGRIDROWHEADER_stateNormalCurrentRow = "NormalCurrentRow";
private const string DATAGRIDROWHEADER_stateNormalCurrentRowLegacy = "Normal CurrentRow";
private const string DATAGRIDROWHEADER_stateNormalEditingRow = "UnfocusedEditingRow";
private const string DATAGRIDROWHEADER_stateNormalEditingRowLegacy = "Unfocused EditingRow";
private const string DATAGRIDROWHEADER_stateNormalEditingRowFocusedLegacy = "NormalEditingRow";
private const string DATAGRIDROWHEADER_stateNormalEditingRowFocused = "Normal EditingRow";
private const string DATAGRIDROWHEADER_stateSelected = "UnfocusedSelected";
private const string DATAGRIDROWHEADER_stateSelectedLegacy = "Unfocused Selected";
private const string DATAGRIDROWHEADER_stateSelectedCurrentRow = "UnfocusedCurrentRowSelected";
private const string DATAGRIDROWHEADER_stateSelectedCurrentRowLegacy = "Unfocused CurrentRow Selected";
private const string DATAGRIDROWHEADER_stateSelectedCurrentRowFocused = "NormalCurrentRowSelected";
private const string DATAGRIDROWHEADER_stateSelectedCurrentRowFocusedLegacy = "Normal CurrentRow Selected";
private const string DATAGRIDROWHEADER_stateSelectedFocused = "NormalSelected";
private const string DATAGRIDROWHEADER_stateSelectedFocusedLegacy = "Normal Selected";
private const byte DATAGRIDROWHEADER_stateMouseOverCode = 0;
private const byte DATAGRIDROWHEADER_stateMouseOverCurrentRowCode = 1;
private const byte DATAGRIDROWHEADER_stateMouseOverEditingRowCode = 2;
private const byte DATAGRIDROWHEADER_stateMouseOverEditingRowFocusedCode = 3;
private const byte DATAGRIDROWHEADER_stateMouseOverSelectedCode = 4;
private const byte DATAGRIDROWHEADER_stateMouseOverSelectedCurrentRowCode = 5;
private const byte DATAGRIDROWHEADER_stateMouseOverSelectedCurrentRowFocusedCode = 6;
private const byte DATAGRIDROWHEADER_stateMouseOverSelectedFocusedCode = 7;
private const byte DATAGRIDROWHEADER_stateNormalCode = 8;
private const byte DATAGRIDROWHEADER_stateNormalCurrentRowCode = 9;
private const byte DATAGRIDROWHEADER_stateNormalEditingRowCode = 10;
private const byte DATAGRIDROWHEADER_stateNormalEditingRowFocusedCode = 11;
private const byte DATAGRIDROWHEADER_stateSelectedCode = 12;
private const byte DATAGRIDROWHEADER_stateSelectedCurrentRowCode = 13;
private const byte DATAGRIDROWHEADER_stateSelectedCurrentRowFocusedCode = 14;
private const byte DATAGRIDROWHEADER_stateSelectedFocusedCode = 15;
private const byte DATAGRIDROWHEADER_stateNullCode = 255;
*/
/*private static byte[] _fallbackStateMapping = new byte[] {
DATAGRIDROWHEADER_stateNormalCode,
DATAGRIDROWHEADER_stateNormalCurrentRowCode,
DATAGRIDROWHEADER_stateMouseOverEditingRowFocusedCode,
DATAGRIDROWHEADER_stateNormalEditingRowFocusedCode,
DATAGRIDROWHEADER_stateMouseOverSelectedFocusedCode,
DATAGRIDROWHEADER_stateMouseOverSelectedCurrentRowFocusedCode,
DATAGRIDROWHEADER_stateSelectedFocusedCode,
DATAGRIDROWHEADER_stateSelectedFocusedCode,
DATAGRIDROWHEADER_stateNullCode,
DATAGRIDROWHEADER_stateNormalCode,
DATAGRIDROWHEADER_stateNormalEditingRowFocusedCode,
DATAGRIDROWHEADER_stateSelectedCurrentRowFocusedCode,
DATAGRIDROWHEADER_stateSelectedFocusedCode,
DATAGRIDROWHEADER_stateSelectedCurrentRowFocusedCode,
DATAGRIDROWHEADER_stateNormalCurrentRowCode,
DATAGRIDROWHEADER_stateNormalCode,
}; */
/*private static byte[] _idealStateMapping = new byte[] {
DATAGRIDROWHEADER_stateNormalCode,
DATAGRIDROWHEADER_stateNormalCode,
DATAGRIDROWHEADER_stateMouseOverCode,
DATAGRIDROWHEADER_stateMouseOverCode,
DATAGRIDROWHEADER_stateNullCode,
DATAGRIDROWHEADER_stateNullCode,
DATAGRIDROWHEADER_stateNullCode,
DATAGRIDROWHEADER_stateNullCode,
DATAGRIDROWHEADER_stateSelectedCode,
DATAGRIDROWHEADER_stateSelectedFocusedCode,
DATAGRIDROWHEADER_stateMouseOverSelectedCode,
DATAGRIDROWHEADER_stateMouseOverSelectedFocusedCode,
DATAGRIDROWHEADER_stateNormalEditingRowCode,
DATAGRIDROWHEADER_stateNormalEditingRowFocusedCode,
DATAGRIDROWHEADER_stateMouseOverEditingRowCode,
DATAGRIDROWHEADER_stateMouseOverEditingRowFocusedCode,
DATAGRIDROWHEADER_stateNormalCurrentRowCode,
DATAGRIDROWHEADER_stateNormalCurrentRowCode,
DATAGRIDROWHEADER_stateMouseOverCurrentRowCode,
DATAGRIDROWHEADER_stateMouseOverCurrentRowCode,
DATAGRIDROWHEADER_stateNullCode,
DATAGRIDROWHEADER_stateNullCode,
DATAGRIDROWHEADER_stateNullCode,
DATAGRIDROWHEADER_stateNullCode,
DATAGRIDROWHEADER_stateSelectedCurrentRowCode,
DATAGRIDROWHEADER_stateSelectedCurrentRowFocusedCode,
DATAGRIDROWHEADER_stateMouseOverSelectedCurrentRowCode,
DATAGRIDROWHEADER_stateMouseOverSelectedCurrentRowFocusedCode,
DATAGRIDROWHEADER_stateNormalEditingRowCode,
DATAGRIDROWHEADER_stateNormalEditingRowFocusedCode,
DATAGRIDROWHEADER_stateMouseOverEditingRowCode,
DATAGRIDROWHEADER_stateMouseOverEditingRowFocusedCode
};*/
// In SL 2, our state names had spaces. Going forward, we are removing the spaces but still
// supporting the legacy state names
/*private static string[] _legacyStateNames = new string[]
{
DATAGRIDROWHEADER_stateMouseOver,
DATAGRIDROWHEADER_stateMouseOverCurrentRowLegacy,
DATAGRIDROWHEADER_stateMouseOverEditingRowLegacy,
DATAGRIDROWHEADER_stateMouseOverEditingRowFocusedLegacy,
DATAGRIDROWHEADER_stateMouseOverSelectedLegacy,
DATAGRIDROWHEADER_stateMouseOverSelectedCurrentRowLegacy,
DATAGRIDROWHEADER_stateMouseOverSelectedCurrentRowFocusedLegacy,
DATAGRIDROWHEADER_stateMouseOverSelectedFocusedLegacy,
DATAGRIDROWHEADER_stateNormal,
DATAGRIDROWHEADER_stateNormalCurrentRowLegacy,
DATAGRIDROWHEADER_stateNormalEditingRowLegacy,
DATAGRIDROWHEADER_stateNormalEditingRowFocusedLegacy,
DATAGRIDROWHEADER_stateSelectedLegacy,
DATAGRIDROWHEADER_stateSelectedCurrentRowLegacy,
DATAGRIDROWHEADER_stateSelectedCurrentRowFocusedLegacy,
DATAGRIDROWHEADER_stateSelectedFocusedLegacy
}; */
/*private static string[] _stateNames = new string[]
{
DATAGRIDROWHEADER_stateMouseOver,
DATAGRIDROWHEADER_stateMouseOverCurrentRow,
DATAGRIDROWHEADER_stateMouseOverEditingRow,
DATAGRIDROWHEADER_stateMouseOverEditingRowFocused,
DATAGRIDROWHEADER_stateMouseOverSelected,
DATAGRIDROWHEADER_stateMouseOverSelectedCurrentRow,
DATAGRIDROWHEADER_stateMouseOverSelectedCurrentRowFocused,
DATAGRIDROWHEADER_stateMouseOverSelectedFocused,
DATAGRIDROWHEADER_stateNormal,
DATAGRIDROWHEADER_stateNormalCurrentRow,
DATAGRIDROWHEADER_stateNormalEditingRow,
DATAGRIDROWHEADER_stateNormalEditingRowFocused,
DATAGRIDROWHEADER_stateSelected,
DATAGRIDROWHEADER_stateSelectedCurrentRow,
DATAGRIDROWHEADER_stateSelectedCurrentRowFocused,
DATAGRIDROWHEADER_stateSelectedFocused
};*/
#endregion Constants
/// <summary>
/// Creates AutomationPeer (<see cref="UIElement.OnCreateAutomationPeer"/>)
/// </summary>
/*protected override AutomationPeer OnCreateAutomationPeer()
{
return new DataGridRowHeaderAutomationPeer(this);
} */
}

45
src/Avalonia.Controls.DataGrid/DataGridRows.cs

@ -313,6 +313,7 @@ namespace Avalonia.Controls
{
int slot = SlotFromRowIndex(rowIndex);
object item = DataConnection.GetDataItem(rowIndex);
// isCollapsed below is always false because we only use the method if we're not grouping
InsertElementAt(slot, rowIndex, item, null/*DataGridRowGroupInfo*/, false /*isCollapsed*/);
}
@ -1039,12 +1040,6 @@ namespace Avalonia.Controls
CompleteCellsCollection(dataGridRow);
OnLoadingRow(new DataGridRowEventArgs(dataGridRow));
//DataGridAutomationPeer peer = DataGridAutomationPeer.FromElement(this) as DataGridAutomationPeer;
//if (peer != null)
//{
// peer.UpdateRowPeerEventsSource(dataGridRow);
//}
}
return dataGridRow;
}
@ -1220,9 +1215,6 @@ namespace Avalonia.Controls
_rowsPresenter.Children.Add(element);
}
groupHeader.LoadVisualsForDisplay();
//Style lastStyle = _rowGroupHeaderStyles.Count > 0 ? _rowGroupHeaderStyles[_rowGroupHeaderStyles.Count - 1] : null;
//EnsureElementStyle(groupHeader, groupHeader.Style, groupHeader.Level < _rowGroupHeaderStyles.Count ? _rowGroupHeaderStyles[groupHeader.Level] : lastStyle);
}
}
@ -1913,12 +1905,6 @@ namespace Avalonia.Controls
Debug.Assert(DoubleUtil.GreaterThanOrClose(NegVerticalOffset, 0));
Debug.Assert(DoubleUtil.GreaterThanOrClose(_verticalOffset, NegVerticalOffset));
//DataGridAutomationPeer peer = DataGridAutomationPeer.FromElement(this) as DataGridAutomationPeer;
//if (peer != null)
//{
// peer.RaiseAutomationScrollEvents();
//}
}
finally
{
@ -2348,7 +2334,6 @@ namespace Avalonia.Controls
}
}
private void ClearRowGroupHeadersTable()
{
// Detach existing handlers on CollectionViewGroup.Items.CollectionChanged
@ -2505,22 +2490,7 @@ namespace Avalonia.Controls
double indent;
for (int i = 0; i < groupLevelCount; i++)
{
//DataGridRowGroupHeader rowGroupHeader = null;
indent = DATAGRID_defaultRowGroupSublevelIndent;
//if (i < RowGroupHeaderStyles.Count && RowGroupHeaderStyles[i] != null)
//{
// // Due to Silverlight Bugs 22038, we have to actually set the Style to read
// // setter values instead of simply enumerating through the setters
// if (rowGroupHeader == null)
// {
// rowGroupHeader = new DataGridRowGroupHeader();
// }
// rowGroupHeader.Style = RowGroupHeaderStyles[i];
// if (rowGroupHeader.SublevelIndent != DataGrid.DATAGRID_defaultRowGroupSublevelIndent)
// {
// indent = rowGroupHeader.SublevelIndent;
// }
//}
indent = DATAGRID_defaultRowGroupSublevelIndent;
RowGroupSublevelIndents[i] = indent;
if (i > 0)
{
@ -2809,13 +2779,7 @@ namespace Avalonia.Controls
groupHeader.UpdateTitleElements();
OnLoadingRowGroup(new DataGridRowGroupHeaderEventArgs(groupHeader));
//DataGridAutomationPeer peer = DataGridAutomationPeer.FromElement(this) as DataGridAutomationPeer;
//if (peer != null)
//{
// peer.UpdateRowGroupHeaderPeerEventsSource(groupHeader);
//}
return groupHeader;
}
@ -3055,7 +3019,6 @@ namespace Avalonia.Controls
}
}
/// <summary>
/// Raises the <see cref="E:Avalonia.Controls.DataGrid.RowDetailsVisibilityChanged" /> event.
/// </summary>
@ -3081,4 +3044,4 @@ namespace Avalonia.Controls
}
#endif
}
}
}

4
src/Avalonia.Controls.DataGrid/DataGridSelectedItemsCollection.cs

@ -208,7 +208,6 @@ namespace Avalonia.Controls
public void CopyTo(System.Array array, int index)
{
//
throw new NotImplementedException();
}
@ -466,7 +465,6 @@ namespace Avalonia.Controls
}
_selectedItemsCache = tempSelectedItemsCache;
}
}
}
}
}

1
src/Avalonia.Controls.DataGrid/DataGridTemplateColumn.cs

@ -30,7 +30,6 @@ namespace Avalonia.Controls
private void OnCellTemplateChanged(AvaloniaPropertyChangedEventArgs e)
{
//CellTemplateProperty.Changed.AddClassHandler<DataGridTemplateColumn>(x => x.OnCellTemplateChanged);
var oldValue = (IDataTemplate)e.OldValue;
var value = (IDataTemplate)e.NewValue;
}

24
src/Avalonia.Controls.DataGrid/DataGridTextColumn.cs

@ -15,18 +15,10 @@ namespace Avalonia.Controls
/// <summary>
/// Represents a <see cref="T:Avalonia.Controls.DataGrid" /> column that hosts textual content in its cells.
/// </summary>
//[StyleTypedProperty(Property = "ElementStyle", StyleTargetType = typeof(TextBlock))]
//[StyleTypedProperty(Property = "EditingElementStyle", StyleTargetType = typeof(TextBox))]
public class DataGridTextColumn : DataGridBoundColumn
{
#region Constants
//private const string DATAGRIDTEXTCOLUMN_fontFamilyName = "FontFamily";
//private const string DATAGRIDTEXTCOLUMN_fontSizeName = "FontSize";
//private const string DATAGRIDTEXTCOLUMN_fontStyleName = "FontStyle";
//private const string DATAGRIDTEXTCOLUMN_fontWeightName = "FontWeight";
//private const string DATAGRIDTEXTCOLUMN_foregroundName = "Foreground";
#endregion Constants
#region Data
@ -48,7 +40,6 @@ namespace Avalonia.Controls
#region DependencyProperties
/// <summary>
/// Identifies the FontFamily dependency property.
/// </summary>
@ -64,19 +55,6 @@ namespace Avalonia.Controls
set { SetValue(FontFamilyProperty, value); }
}
/*private void OnFontFamilyChanged(AvaloniaPropertyChangedEventArgs e)
{
//FontFamilyProperty.Changed.AddClassHandler<DataGridTextColumn>(x => x.OnFontFamilyChanged);
var oldValue = (string)e.OldValue;
var value = (string)e.NewValue;
}*/
/*private static void OnFontFamilyPropertyChanged(AvaloniaObject d, DependencyPropertyChangedEventArgs e)
{
DataGridTextColumn textColumn = (DataGridTextColumn)d;
textColumn.NotifyPropertyChanged(DATAGRIDTEXTCOLUMN_fontFamilyName);
}*/
#endregion DependencyProperties
#region Public Properties
@ -191,7 +169,6 @@ namespace Avalonia.Controls
Background = new SolidColorBrush(Colors.Transparent)
};
//if (DependencyProperty.UnsetValue != ReadLocalValue(DataGridTextColumn.FontFamilyProperty))
if (IsSet(FontFamilyProperty))
{
textBox.FontFamily = FontFamily;
@ -251,7 +228,6 @@ namespace Avalonia.Controls
textBlockElement.Foreground = _foreground;
}
if (Binding != null)
//if (Binding != null || !DesignerProperties.IsInDesignTool)
{
textBlockElement.Bind(TextBlock.TextProperty, Binding);
}

5
src/Avalonia.Controls.DataGrid/EventArgs.cs

@ -171,7 +171,6 @@ namespace Avalonia.Controls
#endregion Properties
}
/// <summary>
/// Provides information after the cell has been pressed.
@ -217,7 +216,6 @@ namespace Avalonia.Controls
public PointerPressedEventArgs PointerPressedEventArgs { get; }
}
/// <summary>
/// Provides information just before a cell exits editing mode.
/// </summary>
@ -523,7 +521,6 @@ namespace Avalonia.Controls
#endregion
}
/// <summary>
/// EventArgs used for the DataGrid's LoadingRowGroup and UnloadingRowGroup events
/// </summary>
@ -585,4 +582,4 @@ namespace Avalonia.Controls
private set;
}
}
}
}

2
src/Avalonia.Controls.DataGrid/Extensions.cs

@ -22,4 +22,4 @@ namespace Avalonia.Controls
}
}
}
}
}

2
src/Avalonia.Controls.DataGrid/Primitives/DataGridCellsPresenter.cs

@ -97,7 +97,7 @@ namespace Avalonia.Controls.Primitives
}
_fillerLeftEdge = scrollingLeftEdge;
// FillerColumn.Width == 0 when the filler column is not active
OwningRow.FillerCell.Arrange(new Rect(_fillerLeftEdge, 0, OwningGrid.ColumnsInternal.FillerColumn.FillerWidth, finalSize.Height));
return finalSize;

8
src/Avalonia.Controls.DataGrid/Primitives/DataGridColumnHeadersPresenter.cs

@ -392,13 +392,5 @@ namespace Avalonia.Controls.Primitives
OwningGrid.ColumnsInternal.EnsureVisibleEdgedColumnsWidth();
return new Size(OwningGrid.ColumnsInternal.VisibleEdgedColumnsWidth, height);
}
/// <summary>
/// Creates AutomationPeer (<see cref="UIElement.OnCreateAutomationPeer"/>)
/// </summary>
//protected override AutomationPeer OnCreateAutomationPeer()
//{
// return new DataGridColumnHeadersPresenterAutomationPeer(this);
//}
}
}

5
src/Avalonia.Controls.DataGrid/Primitives/DataGridDetailsPresenter.cs

@ -132,10 +132,5 @@ namespace Avalonia.Controls.Primitives
return new Size(desiredWidth, desiredHeight);
}
//protected override AutomationPeer OnCreateAutomationPeer()
//{
// return new DataGridDetailsPresenterAutomationPeer(this);
//}
}
}

9
src/Avalonia.Controls.DataGrid/Primitives/DataGridRowsPresenter.cs

@ -161,15 +161,6 @@ namespace Avalonia.Controls.Primitives
return new Size(totalCellsWidth + headerWidth, totalHeight);
}
// / <summary>
// / Creates AutomationPeer (<see cref="UIElement.OnCreateAutomationPeer"/>)
// / </summary>
//Automation
//protected override AutomationPeer OnCreateAutomationPeer()
//{
// return new DataGridRowsPresenterAutomationPeer(this);
//}
#if DEBUG
internal void PrintChildren()

2
src/Avalonia.Controls.DataGrid/Range.cs

@ -66,4 +66,4 @@ namespace Avalonia.Controls
return new Range<T>(LowerBound, UpperBound, Value);
}
}
}
}

2
src/Avalonia.Controls.DataGrid/Utils/CellEditBinding.cs

@ -157,4 +157,4 @@ namespace Avalonia.Controls.Utils
}
}
}
}
}

1
src/Avalonia.Controls.DataGrid/Utils/ReflectionHelper.cs

@ -467,7 +467,6 @@ namespace Avalonia.Controls.Utils
return propertyPaths;
}
/// <summary>
/// Checks a MemberInfo object (e.g. a Type or PropertyInfo) for the ReadOnly attribute
/// and returns the value of IsReadOnly if it exists.

1
src/Avalonia.Themes.Default/DataGrid.xaml

@ -192,7 +192,6 @@
<!--FIX-->
<Style Selector="DataGrid">
<Setter Property="RowBackground" Value="{DynamicResource ThemeAccentBrush4}" />
<!--<Setter Property="RowBackground" Value="#AAEAEFF4" />-->
<Setter Property="AlternatingRowBackground" Value="#00FFFFFF" />
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}" />
<Setter Property="HeadersVisibility" Value="Column" />

Loading…
Cancel
Save