Merge branch 'dev/new-animations' into feature/animation-apis-revamp
This commit is contained in:
Коммит
ffc309a5ee
|
@ -143,12 +143,14 @@ namespace Microsoft.Toolkit.HighPerformance.Helpers
|
|||
end = Math.Min(high, this.memory.Length);
|
||||
|
||||
ref TItem r0 = ref MemoryMarshal.GetReference(this.memory.Span);
|
||||
ref TItem rStart = ref Unsafe.Add(ref r0, low);
|
||||
ref TItem rEnd = ref Unsafe.Add(ref r0, end);
|
||||
|
||||
for (int j = low; j < end; j++)
|
||||
while (Unsafe.IsAddressLessThan(ref rStart, ref rEnd))
|
||||
{
|
||||
ref TItem rj = ref Unsafe.Add(ref r0, (nint)(uint)j);
|
||||
Unsafe.AsRef(this.action).Invoke(in rStart);
|
||||
|
||||
Unsafe.AsRef(this.action).Invoke(rj);
|
||||
rStart = ref Unsafe.Add(ref rStart, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,13 +145,14 @@ namespace Microsoft.Toolkit.HighPerformance.Helpers
|
|||
|
||||
for (int y = lowY; y < stopY; y++)
|
||||
{
|
||||
ref TItem r0 = ref span.DangerousGetReferenceAt(y, 0);
|
||||
ref TItem rStart = ref span.DangerousGetReferenceAt(y, 0);
|
||||
ref TItem rEnd = ref Unsafe.Add(ref rStart, width);
|
||||
|
||||
for (int x = 0; x < width; x++)
|
||||
while (Unsafe.IsAddressLessThan(ref rStart, ref rEnd))
|
||||
{
|
||||
ref TItem ryx = ref Unsafe.Add(ref r0, (nint)(uint)x);
|
||||
Unsafe.AsRef(this.action).Invoke(in rStart);
|
||||
|
||||
Unsafe.AsRef(this.action).Invoke(ryx);
|
||||
rStart = ref Unsafe.Add(ref rStart, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,12 +143,14 @@ namespace Microsoft.Toolkit.HighPerformance.Helpers
|
|||
end = Math.Min(high, this.memory.Length);
|
||||
|
||||
ref TItem r0 = ref MemoryMarshal.GetReference(this.memory.Span);
|
||||
ref TItem rStart = ref Unsafe.Add(ref r0, low);
|
||||
ref TItem rEnd = ref Unsafe.Add(ref r0, end);
|
||||
|
||||
for (int j = low; j < end; j++)
|
||||
while (Unsafe.IsAddressLessThan(ref rStart, ref rEnd))
|
||||
{
|
||||
ref TItem rj = ref Unsafe.Add(ref r0, (nint)(uint)j);
|
||||
Unsafe.AsRef(this.action).Invoke(ref rStart);
|
||||
|
||||
Unsafe.AsRef(this.action).Invoke(ref rj);
|
||||
rStart = ref Unsafe.Add(ref rStart, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,13 +152,14 @@ namespace Microsoft.Toolkit.HighPerformance.Helpers
|
|||
|
||||
for (int y = lowY; y < stopY; y++)
|
||||
{
|
||||
ref TItem r0 = ref span.DangerousGetReferenceAt(y, 0);
|
||||
ref TItem rStart = ref span.DangerousGetReferenceAt(y, 0);
|
||||
ref TItem rEnd = ref Unsafe.Add(ref rStart, width);
|
||||
|
||||
for (int x = 0; x < width; x++)
|
||||
while (Unsafe.IsAddressLessThan(ref rStart, ref rEnd))
|
||||
{
|
||||
ref TItem ryx = ref Unsafe.Add(ref r0, (nint)(uint)x);
|
||||
Unsafe.AsRef(this.action).Invoke(ref rStart);
|
||||
|
||||
Unsafe.AsRef(this.action).Invoke(ref ryx);
|
||||
rStart = ref Unsafe.Add(ref rStart, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -628,15 +628,18 @@ namespace Microsoft.Toolkit.HighPerformance.Memory
|
|||
nint width = (nint)(uint)this.width;
|
||||
|
||||
ref T destinationRef = ref MemoryMarshal.GetReference(destination);
|
||||
nint offset = 0;
|
||||
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
ref T sourceRef = ref DangerousGetReferenceAt(i, 0);
|
||||
ref T sourceStart = ref DangerousGetReferenceAt(i, 0);
|
||||
ref T sourceEnd = ref Unsafe.Add(ref sourceStart, width);
|
||||
|
||||
for (nint j = 0; j < width; j += 1, offset += 1)
|
||||
while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd))
|
||||
{
|
||||
Unsafe.Add(ref destinationRef, offset) = Unsafe.Add(ref sourceRef, j);
|
||||
destinationRef = sourceStart;
|
||||
|
||||
sourceStart = ref Unsafe.Add(ref sourceStart, 1);
|
||||
destinationRef = ref Unsafe.Add(ref destinationRef, 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -682,12 +685,16 @@ namespace Microsoft.Toolkit.HighPerformance.Memory
|
|||
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
ref T sourceRef = ref DangerousGetReferenceAt(i, 0);
|
||||
ref T sourceStart = ref DangerousGetReferenceAt(i, 0);
|
||||
ref T sourceEnd = ref Unsafe.Add(ref sourceStart, width);
|
||||
ref T destinationRef = ref destination.DangerousGetReferenceAt(i, 0);
|
||||
|
||||
for (nint j = 0; j < width; j += 1)
|
||||
while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd))
|
||||
{
|
||||
Unsafe.Add(ref destinationRef, j) = Unsafe.Add(ref sourceRef, j);
|
||||
destinationRef = sourceStart;
|
||||
|
||||
sourceStart = ref Unsafe.Add(ref sourceStart, 1);
|
||||
destinationRef = ref Unsafe.Add(ref destinationRef, 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -928,15 +935,18 @@ namespace Microsoft.Toolkit.HighPerformance.Memory
|
|||
nint width = (nint)(uint)this.width;
|
||||
|
||||
ref T destinationRef = ref array.DangerousGetReference();
|
||||
nint offset = 0;
|
||||
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
ref T sourceRef = ref DangerousGetReferenceAt(i, 0);
|
||||
ref T sourceStart = ref DangerousGetReferenceAt(i, 0);
|
||||
ref T sourceEnd = ref Unsafe.Add(ref sourceStart, width);
|
||||
|
||||
for (nint j = 0; j < width; j += 1, offset += 1)
|
||||
while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd))
|
||||
{
|
||||
Unsafe.Add(ref destinationRef, offset) = Unsafe.Add(ref sourceRef, j);
|
||||
destinationRef = sourceStart;
|
||||
|
||||
sourceStart = ref Unsafe.Add(ref sourceStart, 1);
|
||||
destinationRef = ref Unsafe.Add(ref destinationRef, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -691,11 +691,14 @@ namespace Microsoft.Toolkit.HighPerformance.Memory
|
|||
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
ref T r0 = ref DangerousGetReferenceAt(i, 0);
|
||||
ref T rStart = ref DangerousGetReferenceAt(i, 0);
|
||||
ref T rEnd = ref Unsafe.Add(ref rStart, width);
|
||||
|
||||
for (nint j = 0; j < width; j += 1)
|
||||
while (Unsafe.IsAddressLessThan(ref rStart, ref rEnd))
|
||||
{
|
||||
Unsafe.Add(ref r0, j) = default!;
|
||||
rStart = default!;
|
||||
|
||||
rStart = ref Unsafe.Add(ref rStart, 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -738,15 +741,18 @@ namespace Microsoft.Toolkit.HighPerformance.Memory
|
|||
nint width = (nint)(uint)this.width;
|
||||
|
||||
ref T destinationRef = ref MemoryMarshal.GetReference(destination);
|
||||
nint offset = 0;
|
||||
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
ref T sourceRef = ref DangerousGetReferenceAt(i, 0);
|
||||
ref T sourceStart = ref DangerousGetReferenceAt(i, 0);
|
||||
ref T sourceEnd = ref Unsafe.Add(ref sourceStart, width);
|
||||
|
||||
for (nint j = 0; j < width; j += 1, offset += 1)
|
||||
while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd))
|
||||
{
|
||||
Unsafe.Add(ref destinationRef, offset) = Unsafe.Add(ref sourceRef, j);
|
||||
destinationRef = sourceStart;
|
||||
|
||||
sourceStart = ref Unsafe.Add(ref sourceStart, 1);
|
||||
destinationRef = ref Unsafe.Add(ref destinationRef, 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -792,12 +798,16 @@ namespace Microsoft.Toolkit.HighPerformance.Memory
|
|||
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
ref T sourceRef = ref DangerousGetReferenceAt(i, 0);
|
||||
ref T sourceStart = ref DangerousGetReferenceAt(i, 0);
|
||||
ref T sourceEnd = ref Unsafe.Add(ref sourceStart, width);
|
||||
ref T destinationRef = ref destination.DangerousGetReferenceAt(i, 0);
|
||||
|
||||
for (nint j = 0; j < width; j += 1)
|
||||
while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd))
|
||||
{
|
||||
Unsafe.Add(ref destinationRef, j) = Unsafe.Add(ref sourceRef, j);
|
||||
destinationRef = sourceStart;
|
||||
|
||||
sourceStart = ref Unsafe.Add(ref sourceStart, 1);
|
||||
destinationRef = ref Unsafe.Add(ref destinationRef, 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -868,11 +878,14 @@ namespace Microsoft.Toolkit.HighPerformance.Memory
|
|||
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
ref T r0 = ref DangerousGetReferenceAt(i, 0);
|
||||
ref T rStart = ref DangerousGetReferenceAt(i, 0);
|
||||
ref T rEnd = ref Unsafe.Add(ref rStart, width);
|
||||
|
||||
for (nint j = 0; j < width; j += 1)
|
||||
while (Unsafe.IsAddressLessThan(ref rStart, ref rEnd))
|
||||
{
|
||||
Unsafe.Add(ref r0, j) = value;
|
||||
rStart = value;
|
||||
|
||||
rStart = ref Unsafe.Add(ref rStart, 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1078,15 +1091,18 @@ namespace Microsoft.Toolkit.HighPerformance.Memory
|
|||
nint width = (nint)(uint)this.width;
|
||||
|
||||
ref T destinationRef = ref array.DangerousGetReference();
|
||||
nint offset = 0;
|
||||
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
ref T sourceRef = ref DangerousGetReferenceAt(i, 0);
|
||||
ref T sourceStart = ref DangerousGetReferenceAt(i, 0);
|
||||
ref T sourceEnd = ref Unsafe.Add(ref sourceStart, width);
|
||||
|
||||
for (nint j = 0; j < width; j += 1, offset += 1)
|
||||
while (Unsafe.IsAddressLessThan(ref sourceStart, ref sourceEnd))
|
||||
{
|
||||
Unsafe.Add(ref destinationRef, offset) = Unsafe.Add(ref sourceRef, j);
|
||||
destinationRef = sourceStart;
|
||||
|
||||
sourceStart = ref Unsafe.Add(ref sourceStart, 1);
|
||||
destinationRef = ref Unsafe.Add(ref destinationRef, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -195,8 +195,8 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
|
|||
{
|
||||
try
|
||||
{
|
||||
var pageInstance = Activator.CreateInstance(CurrentSample.PageType);
|
||||
SampleContent.Content = pageInstance;
|
||||
SamplePage = Activator.CreateInstance(CurrentSample.PageType) as Page;
|
||||
SampleContent.Content = SamplePage;
|
||||
|
||||
// Some samples use the OnNavigatedTo and OnNavigatedFrom
|
||||
// Can't use Frame here because some samples depend on the current Frame
|
||||
|
@ -206,7 +206,7 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
|
|||
|
||||
if (method != null)
|
||||
{
|
||||
method.Invoke(pageInstance, new object[] { e });
|
||||
method.Invoke(SamplePage, new object[] { e });
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
@ -348,6 +348,8 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
|
|||
|
||||
private void SamplePage_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
SamplePage.Loaded -= SamplePage_Loaded;
|
||||
|
||||
if (CurrentSample != null && CurrentSample.HasXAMLCode)
|
||||
{
|
||||
_lastRenderedProperties = true;
|
||||
|
@ -516,17 +518,23 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
|
|||
if (CurrentSample.HasType)
|
||||
{
|
||||
root = SamplePage?.FindDescendantByName("XamlRoot");
|
||||
}
|
||||
|
||||
if (root is Panel)
|
||||
{
|
||||
// If we've defined a 'XamlRoot' element to host us as a panel, use that.
|
||||
(root as Panel).Children.Clear();
|
||||
(root as Panel).Children.Add(element);
|
||||
if (root is Panel)
|
||||
{
|
||||
// If we've defined a 'XamlRoot' element to host us as a panel, use that.
|
||||
(root as Panel).Children.Clear();
|
||||
(root as Panel).Children.Add(element);
|
||||
}
|
||||
else
|
||||
{
|
||||
// if we didn't find a XamlRoot host, then we replace the entire content of
|
||||
// the provided sample page with the XAML.
|
||||
SamplePage.Content = element;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, just replace the entire page's content
|
||||
// Otherwise, just replace our entire presenter's content
|
||||
SampleContent.Content = element;
|
||||
}
|
||||
|
||||
|
@ -675,7 +683,8 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
|
|||
}
|
||||
}
|
||||
|
||||
private Page SamplePage => SampleContent.Content as Page;
|
||||
// The Loaded Instance of the backing .xaml.cs Page (if any)
|
||||
private Page SamplePage { get; set; }
|
||||
|
||||
private bool CanChangePaneState => !_onlyDocumentation;
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ using System.Diagnostics;
|
|||
using System.Reflection; // ConstructorInfo
|
||||
#endif
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Data.Utilities
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -563,7 +565,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Data.Utilities
|
|||
BeginAddNew(newItem, index);
|
||||
}
|
||||
|
||||
Debug.Assert(_newItemIndex != -2 && object.Equals(newItem, _newItem), "AddNew did not raise expected events");
|
||||
DiagnosticsDebug.Assert(_newItemIndex != -2 && object.Equals(newItem, _newItem), "AddNew did not raise expected events");
|
||||
|
||||
MoveCurrentTo(newItem);
|
||||
|
||||
|
@ -588,7 +590,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Data.Utilities
|
|||
// related to AddNew. This method is called from ProcessCollectionChanged.
|
||||
private void BeginAddNew(object newItem, int index)
|
||||
{
|
||||
Debug.Assert(_newItemIndex == -2 && _newItem == NoNewItem, "unexpected call to BeginAddNew");
|
||||
DiagnosticsDebug.Assert(_newItemIndex == -2 && _newItem == NoNewItem, "unexpected call to BeginAddNew");
|
||||
|
||||
// remember the new item and its position in the underlying list
|
||||
SetNewItem(newItem);
|
||||
|
@ -810,7 +812,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Data.Utilities
|
|||
{
|
||||
if (!object.Equals(item, _newItem))
|
||||
{
|
||||
Debug.Assert(item == NoNewItem || this._newItem == NoNewItem, "Old and new _newItem values are unexpectedly different from NoNewItem");
|
||||
DiagnosticsDebug.Assert(item == NoNewItem || this._newItem == NoNewItem, "Old and new _newItem values are unexpectedly different from NoNewItem");
|
||||
_newItem = item;
|
||||
|
||||
OnPropertyChanged(CurrentAddItemPropertyName);
|
||||
|
@ -1193,7 +1195,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Data.Utilities
|
|||
{
|
||||
if (!object.Equals(item, _editItem))
|
||||
{
|
||||
Debug.Assert(item == null || _editItem == null, "Old and new _editItem values are unexpectedly non null");
|
||||
DiagnosticsDebug.Assert(item == null || _editItem == null, "Old and new _editItem values are unexpectedly non null");
|
||||
_editItem = item;
|
||||
|
||||
OnPropertyChanged(CurrentEditItemPropertyName);
|
||||
|
@ -1543,7 +1545,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Data.Utilities
|
|||
break;
|
||||
|
||||
default:
|
||||
Debug.Assert(false, "Unexpected Effective Collection Change Action");
|
||||
DiagnosticsDebug.Assert(false, "Unexpected Effective Collection Change Action");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1571,7 +1573,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Data.Utilities
|
|||
// so any changes to the current item will only be raised once, and from this method
|
||||
// _currentChangedMonitor is used to guard whether the CurrentChanged and CurrentChanging event can be fired
|
||||
// so by entering it we're preventing the base calls from firing those events.
|
||||
Debug.Assert(!CurrentChangedMonitor.Busy, "Expected _currentChangedMonitor.Busy is false.");
|
||||
DiagnosticsDebug.Assert(!CurrentChangedMonitor.Busy, "Expected _currentChangedMonitor.Busy is false.");
|
||||
|
||||
CurrentChangedMonitor.Enter();
|
||||
using (CurrentChangedMonitor)
|
||||
|
@ -1910,23 +1912,23 @@ namespace Microsoft.Toolkit.Uwp.UI.Data.Utilities
|
|||
switch (e.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
Debug.Assert(e.NewItems.Count == 1, "Unexpected NotifyCollectionChangedEventArgs.NewItems.Count for Add action");
|
||||
DiagnosticsDebug.Assert(e.NewItems.Count == 1, "Unexpected NotifyCollectionChangedEventArgs.NewItems.Count for Add action");
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Remove:
|
||||
Debug.Assert(e.OldItems.Count == 1, "Unexpected NotifyCollectionChangedEventArgs.OldItems.Count for Remove action");
|
||||
DiagnosticsDebug.Assert(e.OldItems.Count == 1, "Unexpected NotifyCollectionChangedEventArgs.OldItems.Count for Remove action");
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Replace:
|
||||
Debug.Assert(e.OldItems.Count == 1, "Unexpected NotifyCollectionChangedEventArgs.OldItems.Count for Replace action");
|
||||
Debug.Assert(e.NewItems.Count == 1, "Unexpected NotifyCollectionChangedEventArgs.NewItems.Count for Replace action");
|
||||
DiagnosticsDebug.Assert(e.OldItems.Count == 1, "Unexpected NotifyCollectionChangedEventArgs.OldItems.Count for Replace action");
|
||||
DiagnosticsDebug.Assert(e.NewItems.Count == 1, "Unexpected NotifyCollectionChangedEventArgs.NewItems.Count for Replace action");
|
||||
break;
|
||||
|
||||
case NotifyCollectionChangedAction.Reset:
|
||||
break;
|
||||
|
||||
default:
|
||||
Debug.Assert(false, "Unexpected NotifyCollectionChangedEventArgs action");
|
||||
DiagnosticsDebug.Assert(false, "Unexpected NotifyCollectionChangedEventArgs action");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2308,7 +2310,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Data.Utilities
|
|||
|
||||
if (_sort != null)
|
||||
{
|
||||
Debug.Assert(_sort.Count == 0, "must be empty SortDescription collection");
|
||||
DiagnosticsDebug.Assert(_sort.Count == 0, "must be empty SortDescription collection");
|
||||
((INotifyCollectionChanged)_sort).CollectionChanged += new NotifyCollectionChangedEventHandler(SortDescriptionsChanged);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ using Windows.UI.Xaml.Controls;
|
|||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Automation.Peers
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -286,8 +288,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Automation.Peers
|
|||
column++;
|
||||
}
|
||||
|
||||
Debug.Assert(column >= 0, "Expected positive column value.");
|
||||
Debug.Assert(column < this.OwningDataGrid.ColumnsItemsInternal.Count, "Expected smaller column value.");
|
||||
DiagnosticsDebug.Assert(column >= 0, "Expected positive column value.");
|
||||
DiagnosticsDebug.Assert(column < this.OwningDataGrid.ColumnsItemsInternal.Count, "Expected smaller column value.");
|
||||
DataGridCell cell = dgr.Cells[column];
|
||||
AutomationPeer peer = CreatePeerForElement(cell);
|
||||
if (peer != null)
|
||||
|
@ -557,8 +559,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Automation.Peers
|
|||
DataGridRow row = this.OwningDataGrid.DisplayData.GetDisplayedElement(slot) as DataGridRow;
|
||||
if (row != null)
|
||||
{
|
||||
Debug.Assert(column >= 0, "Expected positive column value.");
|
||||
Debug.Assert(column < this.OwningDataGrid.ColumnsItemsInternal.Count, "Expected smaller column value.");
|
||||
DiagnosticsDebug.Assert(column >= 0, "Expected positive column value.");
|
||||
DiagnosticsDebug.Assert(column < this.OwningDataGrid.ColumnsItemsInternal.Count, "Expected smaller column value.");
|
||||
DataGridCell cell = row.Cells[column];
|
||||
return CreatePeerForElement(cell);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ using Windows.UI.Xaml.Automation.Peers;
|
|||
using Windows.UI.Xaml.Automation.Provider;
|
||||
using Windows.UI.Xaml.Data;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Automation.Peers
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -467,8 +469,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Automation.Peers
|
|||
{
|
||||
// Adjust the row index to be relative to the DataGrid instead of the group
|
||||
row = groupInfo.Slot - this.OwningDataGrid.RowGroupHeadersTable.GetIndexCount(0, groupInfo.Slot) + row + 1;
|
||||
Debug.Assert(row >= 0, "Expected positive row.");
|
||||
Debug.Assert(row < this.OwningDataGrid.DataConnection.Count, "Expected row smaller than this.OwningDataGrid.DataConnection.Count.");
|
||||
DiagnosticsDebug.Assert(row >= 0, "Expected positive row.");
|
||||
DiagnosticsDebug.Assert(row < this.OwningDataGrid.DataConnection.Count, "Expected row smaller than this.OwningDataGrid.DataConnection.Count.");
|
||||
int slot = this.OwningDataGrid.SlotFromRowIndex(row);
|
||||
|
||||
if (!this.OwningDataGrid.IsSlotVisible(slot))
|
||||
|
@ -477,12 +479,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Automation.Peers
|
|||
this.OwningDataGrid.ScrollIntoView(item, this.OwningDataGrid.Columns[column]);
|
||||
}
|
||||
|
||||
Debug.Assert(this.OwningDataGrid.IsSlotVisible(slot), "Expected OwningDataGrid.IsSlotVisible(slot) is true.");
|
||||
DiagnosticsDebug.Assert(this.OwningDataGrid.IsSlotVisible(slot), "Expected OwningDataGrid.IsSlotVisible(slot) is true.");
|
||||
|
||||
DataGridRow dgr = this.OwningDataGrid.DisplayData.GetDisplayedElement(slot) as DataGridRow;
|
||||
|
||||
// the first cell is always the indentation filler cell if grouping is enabled, so skip it
|
||||
Debug.Assert(column + 1 < dgr.Cells.Count, "Expected column + 1 smaller than dgr.Cells.Count.");
|
||||
DiagnosticsDebug.Assert(column + 1 < dgr.Cells.Count, "Expected column + 1 smaller than dgr.Cells.Count.");
|
||||
DataGridCell cell = dgr.Cells[column + 1];
|
||||
AutomationPeer peer = CreatePeerForElement(cell);
|
||||
if (peer != null)
|
||||
|
|
|
@ -34,6 +34,8 @@ using Windows.UI.Xaml.Input;
|
|||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Media.Animation;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -1422,7 +1424,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
DataGrid dataGrid = d as DataGrid;
|
||||
if (!dataGrid.IsHandlerSuspended(e.Property))
|
||||
{
|
||||
Debug.Assert(dataGrid.DataConnection != null, "Expected non-null DataConnection.");
|
||||
DiagnosticsDebug.Assert(dataGrid.DataConnection != null, "Expected non-null DataConnection.");
|
||||
|
||||
if (dataGrid.LoadingOrUnloadingRow)
|
||||
{
|
||||
|
@ -2221,7 +2223,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return null;
|
||||
}
|
||||
|
||||
Debug.Assert(this.CurrentColumnIndex < this.ColumnsItemsInternal.Count, "Expected CurrentColumnIndex smaller than ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(this.CurrentColumnIndex < this.ColumnsItemsInternal.Count, "Expected CurrentColumnIndex smaller than ColumnsItemsInternal.Count.");
|
||||
return this.ColumnsItemsInternal[this.CurrentColumnIndex];
|
||||
}
|
||||
|
||||
|
@ -2266,7 +2268,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
|
||||
this.UpdateSelectionAndCurrency(dataGridColumn.Index, this.CurrentSlot, DataGridSelectionAction.None, false /*scrollIntoView*/);
|
||||
Debug.Assert(_successfullyUpdatedSelection, "Expected _successfullyUpdatedSelection is true.");
|
||||
DiagnosticsDebug.Assert(_successfullyUpdatedSelection, "Expected _successfullyUpdatedSelection is true.");
|
||||
if (beginEdit &&
|
||||
_editingColumnIndex == -1 &&
|
||||
this.CurrentSlot != -1 &&
|
||||
|
@ -2494,7 +2496,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
set
|
||||
{
|
||||
Debug.Assert(!value || (this.ColumnHeaders != null && this.AreColumnHeadersVisible), "Expected value==False || (non-null ColumnHeaders and AreColumnHeadersVisible==True)");
|
||||
DiagnosticsDebug.Assert(!value || (this.ColumnHeaders != null && this.AreColumnHeadersVisible), "Expected value==False || (non-null ColumnHeaders and AreColumnHeadersVisible==True)");
|
||||
|
||||
if (_columnHeaderHasFocus != value)
|
||||
{
|
||||
|
@ -2717,7 +2719,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
set
|
||||
{
|
||||
Debug.Assert(value >= 0, "Expected positive NoCurrentCellChangeCount.");
|
||||
DiagnosticsDebug.Assert(value >= 0, "Expected positive NoCurrentCellChangeCount.");
|
||||
_noCurrentCellChangeCount = value;
|
||||
if (value == 0)
|
||||
{
|
||||
|
@ -3056,7 +3058,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
set
|
||||
{
|
||||
Debug.Assert(value >= 0, "Expected positive NoSelectionChangeCount.");
|
||||
DiagnosticsDebug.Assert(value >= 0, "Expected positive NoSelectionChangeCount.");
|
||||
_noSelectionChangeCount = value;
|
||||
if (value == 0)
|
||||
{
|
||||
|
@ -3086,11 +3088,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return false;
|
||||
}
|
||||
|
||||
Debug.Assert(this.CurrentColumnIndex >= 0, "Expected positive CurrentColumnIndex.");
|
||||
Debug.Assert(this.CurrentColumnIndex < this.ColumnsItemsInternal.Count, "Expected CurrentColumnIndex smaller than ColumnsItemsInternal.Count.");
|
||||
Debug.Assert(this.CurrentSlot >= -1, "Expected CurrentSlot greater than or equal to -1.");
|
||||
Debug.Assert(this.CurrentSlot < this.SlotCount, "Expected CurrentSlot smaller than SlotCount.");
|
||||
Debug.Assert(this.EditingRow == null || this.EditingRow.Slot == this.CurrentSlot, "Expected null EditingRow or EditingRow.Slot equal to CurrentSlot.");
|
||||
DiagnosticsDebug.Assert(this.CurrentColumnIndex >= 0, "Expected positive CurrentColumnIndex.");
|
||||
DiagnosticsDebug.Assert(this.CurrentColumnIndex < this.ColumnsItemsInternal.Count, "Expected CurrentColumnIndex smaller than ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(this.CurrentSlot >= -1, "Expected CurrentSlot greater than or equal to -1.");
|
||||
DiagnosticsDebug.Assert(this.CurrentSlot < this.SlotCount, "Expected CurrentSlot smaller than SlotCount.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow == null || this.EditingRow.Slot == this.CurrentSlot, "Expected null EditingRow or EditingRow.Slot equal to CurrentSlot.");
|
||||
|
||||
if (GetColumnEffectiveReadOnlyState(this.CurrentColumn))
|
||||
{
|
||||
|
@ -3237,7 +3239,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
else
|
||||
{
|
||||
rowGroupInfo = this.RowGroupHeadersTable.GetValueAt(this.RowGroupHeadersTable.GetPreviousIndex(slot));
|
||||
Debug.Assert(rowGroupInfo != null, "Expected non-null rowGroupInfo.");
|
||||
DiagnosticsDebug.Assert(rowGroupInfo != null, "Expected non-null rowGroupInfo.");
|
||||
if (rowGroupInfo != null)
|
||||
{
|
||||
ExpandRowGroupParentChain(rowGroupInfo.Level, rowGroupInfo.Slot);
|
||||
|
@ -3474,7 +3476,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
_validationSummary.SelectionChanged += new EventHandler<SelectionChangedEventArgs>(ValidationSummary_SelectionChanged);
|
||||
if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
|
||||
{
|
||||
Debug.Assert(_validationSummary.Errors != null);
|
||||
DiagnosticsDebug.Assert(_validationSummary.Errors != null);
|
||||
|
||||
// Do not add the default design time errors when in design mode.
|
||||
_validationSummary.Errors.Clear();
|
||||
|
@ -3645,7 +3647,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
EventHandler<DataGridRowEventArgs> handler = this.LoadingRow;
|
||||
if (handler != null)
|
||||
{
|
||||
Debug.Assert(!_loadedRows.Contains(e.Row), "Expected e.Rows not contained in _loadedRows.");
|
||||
DiagnosticsDebug.Assert(!_loadedRows.Contains(e.Row), "Expected e.Rows not contained in _loadedRows.");
|
||||
_loadedRows.Add(e.Row);
|
||||
this.LoadingOrUnloadingRow = true;
|
||||
try
|
||||
|
@ -3655,7 +3657,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
finally
|
||||
{
|
||||
this.LoadingOrUnloadingRow = false;
|
||||
Debug.Assert(_loadedRows.Contains(e.Row), "Expected e.Rows contained in _loadedRows.");
|
||||
DiagnosticsDebug.Assert(_loadedRows.Contains(e.Row), "Expected e.Rows contained in _loadedRows.");
|
||||
_loadedRows.Remove(e.Row);
|
||||
}
|
||||
}
|
||||
|
@ -3872,7 +3874,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal static DataGridCell GetOwningCell(FrameworkElement element)
|
||||
{
|
||||
Debug.Assert(element != null, "Expected non-null element.");
|
||||
DiagnosticsDebug.Assert(element != null, "Expected non-null element.");
|
||||
DataGridCell cell = element as DataGridCell;
|
||||
while (element != null && cell == null)
|
||||
{
|
||||
|
@ -4105,7 +4107,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
if (scrollBarValueDifference != 0)
|
||||
{
|
||||
Debug.Assert(_horizontalOffset + scrollBarValueDifference >= 0, "Expected positive _horizontalOffset + scrollBarValueDifference.");
|
||||
DiagnosticsDebug.Assert(_horizontalOffset + scrollBarValueDifference >= 0, "Expected positive _horizontalOffset + scrollBarValueDifference.");
|
||||
SetHorizontalOffset(_horizontalOffset + scrollBarValueDifference);
|
||||
}
|
||||
|
||||
|
@ -4350,12 +4352,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return;
|
||||
}
|
||||
|
||||
Debug.Assert(DoubleUtil.LessThanOrClose(_vScrollBar.Value, _vScrollBar.Maximum), "Expected _vScrollBar.Value smaller than or close to _vScrollBar.Maximum.");
|
||||
DiagnosticsDebug.Assert(DoubleUtil.LessThanOrClose(_vScrollBar.Value, _vScrollBar.Maximum), "Expected _vScrollBar.Value smaller than or close to _vScrollBar.Maximum.");
|
||||
|
||||
_verticalScrollChangesIgnored++;
|
||||
try
|
||||
{
|
||||
Debug.Assert(_vScrollBar != null, "Expected non-null _vScrollBar.");
|
||||
DiagnosticsDebug.Assert(_vScrollBar != null, "Expected non-null _vScrollBar.");
|
||||
if (scrollEventType == ScrollEventType.SmallIncrement)
|
||||
{
|
||||
this.DisplayData.PendingVerticalScrollHeight = GetVerticalSmallScrollIncrease();
|
||||
|
@ -4486,16 +4488,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal bool ScrollSlotIntoView(int columnIndex, int slot, bool forCurrentCellChange, bool forceHorizontalScroll)
|
||||
{
|
||||
Debug.Assert(columnIndex >= 0, "Expected positive columnIndex.");
|
||||
Debug.Assert(columnIndex < this.ColumnsItemsInternal.Count, "Expected columnIndex smaller than ColumnsItemsInternal.Count.");
|
||||
Debug.Assert(this.DisplayData.FirstDisplayedScrollingCol >= -1, "Expected DisplayData.FirstDisplayedScrollingCol greater than or equal to -1.");
|
||||
Debug.Assert(this.DisplayData.FirstDisplayedScrollingCol < this.ColumnsItemsInternal.Count, "Expected smaller than ColumnsItemsInternal.Count.");
|
||||
Debug.Assert(this.DisplayData.LastTotallyDisplayedScrollingCol >= -1, "Expected DisplayData.LastTotallyDisplayedScrollingCol greater than or equal to -1.");
|
||||
Debug.Assert(this.DisplayData.LastTotallyDisplayedScrollingCol < this.ColumnsItemsInternal.Count, "Expected DisplayData.LastTotallyDisplayedScrollingCol smaller than ColumnsItemsInternal.Count.");
|
||||
Debug.Assert(!IsSlotOutOfBounds(slot), "Expected IsSlotOutOfBounds(slot) is false.");
|
||||
Debug.Assert(this.DisplayData.FirstScrollingSlot >= -1, "Expected DisplayData.FirstScrollingSlot greater than or equal to -1.");
|
||||
Debug.Assert(this.DisplayData.FirstScrollingSlot < this.SlotCount, "Expected DisplayData.FirstScrollingSlot smaller than SlotCount.");
|
||||
Debug.Assert(this.ColumnsItemsInternal[columnIndex].IsVisible, "Expected ColumnsItemsInternal[columnIndex].IsVisible is true.");
|
||||
DiagnosticsDebug.Assert(columnIndex >= 0, "Expected positive columnIndex.");
|
||||
DiagnosticsDebug.Assert(columnIndex < this.ColumnsItemsInternal.Count, "Expected columnIndex smaller than ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.FirstDisplayedScrollingCol >= -1, "Expected DisplayData.FirstDisplayedScrollingCol greater than or equal to -1.");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.FirstDisplayedScrollingCol < this.ColumnsItemsInternal.Count, "Expected smaller than ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.LastTotallyDisplayedScrollingCol >= -1, "Expected DisplayData.LastTotallyDisplayedScrollingCol greater than or equal to -1.");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.LastTotallyDisplayedScrollingCol < this.ColumnsItemsInternal.Count, "Expected DisplayData.LastTotallyDisplayedScrollingCol smaller than ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(!IsSlotOutOfBounds(slot), "Expected IsSlotOutOfBounds(slot) is false.");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.FirstScrollingSlot >= -1, "Expected DisplayData.FirstScrollingSlot greater than or equal to -1.");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.FirstScrollingSlot < this.SlotCount, "Expected DisplayData.FirstScrollingSlot smaller than SlotCount.");
|
||||
DiagnosticsDebug.Assert(this.ColumnsItemsInternal[columnIndex].IsVisible, "Expected ColumnsItemsInternal[columnIndex].IsVisible is true.");
|
||||
|
||||
if (this.CurrentColumnIndex >= 0 &&
|
||||
(this.CurrentColumnIndex != columnIndex || this.CurrentSlot != slot))
|
||||
|
@ -4705,7 +4707,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
FrameworkElement editingElement = editingColumn.GetCellContent(this.EditingRow);
|
||||
if (editingElement != null && editingElement.ContainsChild(_focusedObject))
|
||||
{
|
||||
Debug.Assert(_lostFocusActions != null, "Expected non-null _lostFocusActions.");
|
||||
DiagnosticsDebug.Assert(_lostFocusActions != null, "Expected non-null _lostFocusActions.");
|
||||
_lostFocusActions.Enqueue(action);
|
||||
editingElement.LostFocus += new RoutedEventHandler(EditingElement_LostFocus);
|
||||
this.IsTabStop = true;
|
||||
|
@ -4720,7 +4722,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// Applies the given Style to the Row if it's supposed to use DataGrid.RowStyle
|
||||
private static void EnsureElementStyle(FrameworkElement element, Style oldDataGridStyle, Style newDataGridStyle)
|
||||
{
|
||||
Debug.Assert(element != null, "Expected non-null element.");
|
||||
DiagnosticsDebug.Assert(element != null, "Expected non-null element.");
|
||||
|
||||
// Apply the DataGrid style if the row was using the old DataGridRowStyle before
|
||||
if (element != null && (element.Style == null || element.Style == oldDataGridStyle))
|
||||
|
@ -4814,18 +4816,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return false;
|
||||
}
|
||||
|
||||
Debug.Assert(this.CurrentColumnIndex >= 0, "Expected positive CurrentColumnIndex.");
|
||||
Debug.Assert(this.CurrentColumnIndex < this.ColumnsItemsInternal.Count, "Expected CurrentColumnIndex smaller than ColumnsItemsInternal.Count.");
|
||||
Debug.Assert(this.CurrentSlot >= -1, "Expected CurrentSlot greater than or equal to -1.");
|
||||
Debug.Assert(this.CurrentSlot < this.SlotCount, "Expected CurrentSlot smaller than SlotCount.");
|
||||
Debug.Assert(this.EditingRow == null || this.EditingRow.Slot == this.CurrentSlot, "Expected null EditingRow or EditingRow.Slot equal to CurrentSlot.");
|
||||
Debug.Assert(!GetColumnEffectiveReadOnlyState(this.CurrentColumn), "Expected GetColumnEffectiveReadOnlyState(CurrentColumn) is false.");
|
||||
Debug.Assert(this.CurrentColumn.IsVisible, "Expected CurrentColumn.IsVisible is true.");
|
||||
DiagnosticsDebug.Assert(this.CurrentColumnIndex >= 0, "Expected positive CurrentColumnIndex.");
|
||||
DiagnosticsDebug.Assert(this.CurrentColumnIndex < this.ColumnsItemsInternal.Count, "Expected CurrentColumnIndex smaller than ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(this.CurrentSlot >= -1, "Expected CurrentSlot greater than or equal to -1.");
|
||||
DiagnosticsDebug.Assert(this.CurrentSlot < this.SlotCount, "Expected CurrentSlot smaller than SlotCount.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow == null || this.EditingRow.Slot == this.CurrentSlot, "Expected null EditingRow or EditingRow.Slot equal to CurrentSlot.");
|
||||
DiagnosticsDebug.Assert(!GetColumnEffectiveReadOnlyState(this.CurrentColumn), "Expected GetColumnEffectiveReadOnlyState(CurrentColumn) is false.");
|
||||
DiagnosticsDebug.Assert(this.CurrentColumn.IsVisible, "Expected CurrentColumn.IsVisible is true.");
|
||||
|
||||
if (_editingColumnIndex != -1)
|
||||
{
|
||||
// Current cell is already in edit mode
|
||||
Debug.Assert(_editingColumnIndex == this.CurrentColumnIndex, "Expected _editingColumnIndex equals CurrentColumnIndex.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex == this.CurrentColumnIndex, "Expected _editingColumnIndex equals CurrentColumnIndex.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -4839,12 +4841,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
DataGridRow dataGridRow = this.EditingRow;
|
||||
if (dataGridRow == null)
|
||||
{
|
||||
Debug.Assert(!this.RowGroupHeadersTable.Contains(this.CurrentSlot), "Expected CurrentSlot not contained in RowGroupHeadersTable.");
|
||||
DiagnosticsDebug.Assert(!this.RowGroupHeadersTable.Contains(this.CurrentSlot), "Expected CurrentSlot not contained in RowGroupHeadersTable.");
|
||||
|
||||
if (this.IsSlotVisible(this.CurrentSlot))
|
||||
{
|
||||
dataGridRow = this.DisplayData.GetDisplayedElement(this.CurrentSlot) as DataGridRow;
|
||||
Debug.Assert(dataGridRow != null, "Expected non-null dataGridRow.");
|
||||
DiagnosticsDebug.Assert(dataGridRow != null, "Expected non-null dataGridRow.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4860,7 +4862,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
}
|
||||
|
||||
Debug.Assert(dataGridRow != null, "Expected non-null dataGridRow.");
|
||||
DiagnosticsDebug.Assert(dataGridRow != null, "Expected non-null dataGridRow.");
|
||||
|
||||
// Cache these to see if they change later
|
||||
int currentRowIndex = this.CurrentSlot;
|
||||
|
@ -4898,11 +4900,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private bool BeginRowEdit(DataGridRow dataGridRow)
|
||||
{
|
||||
Debug.Assert(this.EditingRow == null, "Expected non-null EditingRow.");
|
||||
Debug.Assert(dataGridRow != null, "Expected non-null dataGridRow.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow == null, "Expected non-null EditingRow.");
|
||||
DiagnosticsDebug.Assert(dataGridRow != null, "Expected non-null dataGridRow.");
|
||||
|
||||
Debug.Assert(this.CurrentSlot >= -1, "Expected CurrentSlot greater than or equal to -1.");
|
||||
Debug.Assert(this.CurrentSlot < this.SlotCount, "Expected CurrentSlot smaller than SlotCount.");
|
||||
DiagnosticsDebug.Assert(this.CurrentSlot >= -1, "Expected CurrentSlot greater than or equal to -1.");
|
||||
DiagnosticsDebug.Assert(this.CurrentSlot < this.SlotCount, "Expected CurrentSlot smaller than SlotCount.");
|
||||
|
||||
if (this.DataConnection.BeginEdit(dataGridRow.DataContext))
|
||||
{
|
||||
|
@ -4930,10 +4932,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return true;
|
||||
}
|
||||
|
||||
Debug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
Debug.Assert(this.EditingRow.Index >= -1, "Expected EditingRow greater or equal to -1.");
|
||||
Debug.Assert(this.EditingRow.Slot < this.SlotCount, "Expected EditingRow smaller than SlotCount.");
|
||||
Debug.Assert(this.CurrentColumn != null, "Expected non-null CurrentColumn.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow.Index >= -1, "Expected EditingRow greater or equal to -1.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow.Slot < this.SlotCount, "Expected EditingRow smaller than SlotCount.");
|
||||
DiagnosticsDebug.Assert(this.CurrentColumn != null, "Expected non-null CurrentColumn.");
|
||||
|
||||
object dataItem = this.EditingRow.DataContext;
|
||||
if (!this.DataConnection.CancelEdit(dataItem))
|
||||
|
@ -5003,9 +5005,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return true;
|
||||
}
|
||||
|
||||
Debug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
Debug.Assert(this.EditingRow.Index >= -1, "Expected EditingRow.Index greater than or equal to -1.");
|
||||
Debug.Assert(this.EditingRow.Slot < this.SlotCount, "Expected EditingRow.Slot smaller than SlotCount.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow.Index >= -1, "Expected EditingRow.Index greater than or equal to -1.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow.Slot < this.SlotCount, "Expected EditingRow.Slot smaller than SlotCount.");
|
||||
|
||||
if (!ValidateEditingRow(true /*scrollIntoView*/, false /*wireEvents*/))
|
||||
{
|
||||
|
@ -5024,7 +5026,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void CompleteCellsCollection(DataGridRow dataGridRow)
|
||||
{
|
||||
Debug.Assert(dataGridRow != null, "Expected non-null dataGridRow.");
|
||||
DiagnosticsDebug.Assert(dataGridRow != null, "Expected non-null dataGridRow.");
|
||||
int cellsInCollection = dataGridRow.Cells.Count;
|
||||
if (this.ColumnsItemsInternal.Count > cellsInCollection)
|
||||
{
|
||||
|
@ -5125,7 +5127,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
double oldDataHeight = cellsHeight;
|
||||
cellsHeight -= horizScrollBarHeight;
|
||||
Debug.Assert(cellsHeight >= 0, "Expected positive cellsHeight.");
|
||||
DiagnosticsDebug.Assert(cellsHeight >= 0, "Expected positive cellsHeight.");
|
||||
needHorizScrollBarWithoutVertScrollBar = needHorizScrollBar = true;
|
||||
|
||||
if (vertScrollBarWidth > 0 &&
|
||||
|
@ -5159,7 +5161,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
this.DisplayData.NumTotallyDisplayedScrollingElements != this.VisibleSlotCount)
|
||||
{
|
||||
cellsWidth -= vertScrollBarWidth;
|
||||
Debug.Assert(cellsWidth >= 0, "Expected positive cellsWidth.");
|
||||
DiagnosticsDebug.Assert(cellsWidth >= 0, "Expected positive cellsWidth.");
|
||||
needVertScrollBar = true;
|
||||
}
|
||||
|
||||
|
@ -5177,7 +5179,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
cellsWidth += vertScrollBarWidth;
|
||||
cellsHeight -= horizScrollBarHeight;
|
||||
Debug.Assert(cellsHeight >= 0, "Expected positive cellsHeight.");
|
||||
DiagnosticsDebug.Assert(cellsHeight >= 0, "Expected positive cellsHeight.");
|
||||
needVertScrollBar = false;
|
||||
|
||||
UpdateDisplayedRows(firstScrollingSlot, cellsHeight);
|
||||
|
@ -5186,7 +5188,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
this.DisplayData.NumTotallyDisplayedScrollingElements != this.VisibleSlotCount)
|
||||
{
|
||||
cellsWidth -= vertScrollBarWidth;
|
||||
Debug.Assert(cellsWidth >= 0, "Expected positive cellsWidth.");
|
||||
DiagnosticsDebug.Assert(cellsWidth >= 0, "Expected positive cellsWidth.");
|
||||
needVertScrollBar = true;
|
||||
}
|
||||
|
||||
|
@ -5209,7 +5211,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
this.DisplayData.NumTotallyDisplayedScrollingElements != this.VisibleSlotCount)
|
||||
{
|
||||
cellsWidth -= vertScrollBarWidth;
|
||||
Debug.Assert(cellsWidth >= 0, "Expected positive cellsWidth.");
|
||||
DiagnosticsDebug.Assert(cellsWidth >= 0, "Expected positive cellsWidth.");
|
||||
needVertScrollBar = true;
|
||||
}
|
||||
|
||||
|
@ -5229,7 +5231,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
DoubleUtil.LessThan(totalVisibleFrozenWidth, cellsWidth))
|
||||
{
|
||||
cellsHeight -= horizScrollBarHeight;
|
||||
Debug.Assert(cellsHeight >= 0, "Expected positive cellsHeight.");
|
||||
DiagnosticsDebug.Assert(cellsHeight >= 0, "Expected positive cellsHeight.");
|
||||
needHorizScrollBar = true;
|
||||
UpdateDisplayedRows(this.DisplayData.FirstScrollingSlot, cellsHeight);
|
||||
}
|
||||
|
@ -5242,10 +5244,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(forceHorizScrollBar, "Expected forceHorizScrollBar is true.");
|
||||
Debug.Assert(forceVertScrollBar, "Expected forceVertScrollBar is true.");
|
||||
Debug.Assert(allowHorizScrollBar, "Expected allowHorizScrollBar is true.");
|
||||
Debug.Assert(allowVertScrollBar, "Expected allowVertScrollBar is true.");
|
||||
DiagnosticsDebug.Assert(forceHorizScrollBar, "Expected forceHorizScrollBar is true.");
|
||||
DiagnosticsDebug.Assert(forceVertScrollBar, "Expected forceVertScrollBar is true.");
|
||||
DiagnosticsDebug.Assert(allowHorizScrollBar, "Expected allowHorizScrollBar is true.");
|
||||
DiagnosticsDebug.Assert(allowVertScrollBar, "Expected allowVertScrollBar is true.");
|
||||
this.DisplayData.FirstDisplayedScrollingCol = ComputeFirstVisibleScrollingColumn();
|
||||
ComputeDisplayedColumns();
|
||||
needVertScrollBar = this.DisplayData.NumTotallyDisplayedScrollingElements != this.VisibleSlotCount;
|
||||
|
@ -5290,9 +5292,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <returns>ValidationSummaryItem</returns>
|
||||
private ValidationSummaryItem CreateValidationSummaryItem(ValidationResult validationResult)
|
||||
{
|
||||
Debug.Assert(validationResult != null);
|
||||
Debug.Assert(_validationSummary != null);
|
||||
Debug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
DiagnosticsDebug.Assert(validationResult != null);
|
||||
DiagnosticsDebug.Assert(_validationSummary != null);
|
||||
DiagnosticsDebug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
|
||||
ValidationSummaryItem validationSummaryItem = new ValidationSummaryItem(validationResult.ErrorMessage);
|
||||
validationSummaryItem.Context = validationResult;
|
||||
|
@ -5313,7 +5315,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
}
|
||||
|
||||
Debug.Assert(validationSummaryItem.ItemType == ValidationSummaryItemType.ObjectError);
|
||||
DiagnosticsDebug.Assert(validationSummaryItem.ItemType == ValidationSummaryItemType.ObjectError);
|
||||
if (_propertyValidationResults.ContainsEqualValidationResult(validationResult))
|
||||
{
|
||||
validationSummaryItem.MessageHeader = messageHeader;
|
||||
|
@ -5341,7 +5343,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
this.FocusEditingCell(true);
|
||||
}
|
||||
|
||||
Debug.Assert(_lostFocusActions != null, "Expected non-null _lostFocusActions.");
|
||||
DiagnosticsDebug.Assert(_lostFocusActions != null, "Expected non-null _lostFocusActions.");
|
||||
try
|
||||
{
|
||||
_executingLostFocusActions = true;
|
||||
|
@ -5462,7 +5464,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <param name="e">FocusingInvalidControlEventArgs</param>
|
||||
private void ValidationSummary_FocusingInvalidControl(object sender, FocusingInvalidControlEventArgs e)
|
||||
{
|
||||
Debug.Assert(_validationSummary != null);
|
||||
DiagnosticsDebug.Assert(_validationSummary != null);
|
||||
if (this.EditingRow == null || this.IsSlotOutOfBounds(this.EditingRow.Slot) || this.EditingRow.Slot == -1 || !ScrollSlotIntoView(this.EditingRow.Slot, false /*scrolledHorizontally*/))
|
||||
{
|
||||
return;
|
||||
|
@ -5475,7 +5477,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
DataGridCell cell = e.Target.Control as DataGridCell;
|
||||
if (cell != null && cell.OwningGrid == this && cell.OwningColumn != null && cell.OwningColumn.IsVisible)
|
||||
{
|
||||
Debug.Assert(cell.ColumnIndex >= 0 && cell.ColumnIndex < this.ColumnsInternal.Count);
|
||||
DiagnosticsDebug.Assert(cell.ColumnIndex >= 0 && cell.ColumnIndex < this.ColumnsInternal.Count);
|
||||
|
||||
// Begin editing the next relevant cell
|
||||
UpdateSelectionAndCurrency(cell.ColumnIndex, this.EditingRow.Slot, DataGridSelectionAction.None, true /*scrollIntoView*/);
|
||||
|
@ -5522,7 +5524,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
while (previousHeaderSlot >= 0)
|
||||
{
|
||||
DataGridRowGroupInfo rowGroupInfo = this.RowGroupHeadersTable.GetValueAt(previousHeaderSlot);
|
||||
Debug.Assert(rowGroupInfo != null, "Expected non-null rowGroupInfo.");
|
||||
DiagnosticsDebug.Assert(rowGroupInfo != null, "Expected non-null rowGroupInfo.");
|
||||
if (level == rowGroupInfo.Level)
|
||||
{
|
||||
if (_collapsedSlotsTable.Contains(rowGroupInfo.Slot))
|
||||
|
@ -5554,8 +5556,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <returns>ValidationSummaryItem or null if not found</returns>
|
||||
private ValidationSummaryItem FindValidationSummaryItem(ValidationResult context)
|
||||
{
|
||||
Debug.Assert(context != null);
|
||||
Debug.Assert(_validationSummary != null);
|
||||
DiagnosticsDebug.Assert(context != null);
|
||||
DiagnosticsDebug.Assert(_validationSummary != null);
|
||||
foreach (ValidationSummaryItem ValidationSummaryItem in _validationSummary.Errors)
|
||||
{
|
||||
if (context.Equals(ValidationSummaryItem.Context))
|
||||
|
@ -5703,7 +5705,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
if (shift && this.LastHandledKeyDown != VirtualKey.Tab)
|
||||
{
|
||||
Debug.Assert(!this.ColumnHeaderHasFocus, "Expected ColumnHeaderHasFocus is false.");
|
||||
DiagnosticsDebug.Assert(!this.ColumnHeaderHasFocus, "Expected ColumnHeaderHasFocus is false.");
|
||||
|
||||
// Show currency on the current column's header as focus is entering the DataGrid backwards.
|
||||
this.ColumnHeaderHasFocus = true;
|
||||
|
@ -5711,7 +5713,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
|
||||
bool success = ScrollSlotIntoView(this.CurrentColumnIndex, this.CurrentSlot, false /*forCurrentCellChange*/, true /*forceHorizontalScroll*/);
|
||||
Debug.Assert(success, "Expected ScrollSlotIntoView returns true.");
|
||||
DiagnosticsDebug.Assert(success, "Expected ScrollSlotIntoView returns true.");
|
||||
if (this.CurrentColumnIndex != -1 && this.SelectedItem == null)
|
||||
{
|
||||
SetRowSelection(this.CurrentSlot, true /*isSelected*/, true /*setAnchorSlot*/);
|
||||
|
@ -5908,11 +5910,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return true;
|
||||
}
|
||||
|
||||
Debug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
Debug.Assert(this.EditingRow.Slot == this.CurrentSlot, "Expected EditingRow.Slot equals CurrentSlot.");
|
||||
Debug.Assert(_editingColumnIndex >= 0, "Expected positive _editingColumnIndex.");
|
||||
Debug.Assert(_editingColumnIndex < this.ColumnsItemsInternal.Count, "Expected _editingColumnIndex smaller than this.ColumnsItemsInternal.Count.");
|
||||
Debug.Assert(_editingColumnIndex == this.CurrentColumnIndex, "Expected _editingColumnIndex equals this.CurrentColumnIndex.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow.Slot == this.CurrentSlot, "Expected EditingRow.Slot equals CurrentSlot.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex >= 0, "Expected positive _editingColumnIndex.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex < this.ColumnsItemsInternal.Count, "Expected _editingColumnIndex smaller than this.ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex == this.CurrentColumnIndex, "Expected _editingColumnIndex equals this.CurrentColumnIndex.");
|
||||
|
||||
// Cache these to see if they change later
|
||||
int currentSlot = this.CurrentSlot;
|
||||
|
@ -5944,10 +5946,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return true;
|
||||
}
|
||||
|
||||
Debug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
Debug.Assert(this.EditingRow.Slot == currentSlot, "Expected EditingRow.Slot equals currentSlot.");
|
||||
Debug.Assert(_editingColumnIndex != -1, "Expected _editingColumnIndex other than -1.");
|
||||
Debug.Assert(_editingColumnIndex == this.CurrentColumnIndex, "Expected _editingColumnIndex equals CurrentColumnIndex.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow.Slot == currentSlot, "Expected EditingRow.Slot equals currentSlot.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex != -1, "Expected _editingColumnIndex other than -1.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex == this.CurrentColumnIndex, "Expected _editingColumnIndex equals CurrentColumnIndex.");
|
||||
}
|
||||
|
||||
_bindingValidationResults.Clear();
|
||||
|
@ -5965,10 +5967,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return true;
|
||||
}
|
||||
|
||||
Debug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
Debug.Assert(this.EditingRow.Slot == currentSlot, "Expected EditingRow.Slot equals currentSlot.");
|
||||
Debug.Assert(_editingColumnIndex != -1, "Expected _editingColumnIndex other than -1.");
|
||||
Debug.Assert(_editingColumnIndex == this.CurrentColumnIndex, "Expected _editingColumnIndex equals CurrentColumnIndex.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow.Slot == currentSlot, "Expected EditingRow.Slot equals currentSlot.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex != -1, "Expected _editingColumnIndex other than -1.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex == this.CurrentColumnIndex, "Expected _editingColumnIndex equals CurrentColumnIndex.");
|
||||
|
||||
// Re-validate
|
||||
this.ValidateEditingRow(true /*scrollIntoView*/, false /*wireEvents*/);
|
||||
|
@ -5979,7 +5981,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
foreach (BindingInfo bindingData in this.CurrentColumn.GetInputBindings(editingElement, this.CurrentItem))
|
||||
{
|
||||
Debug.Assert(bindingData.BindingExpression.ParentBinding != null, "Expected non-null bindingData.BindingExpression.ParentBinding.");
|
||||
DiagnosticsDebug.Assert(bindingData.BindingExpression.ParentBinding != null, "Expected non-null bindingData.BindingExpression.ParentBinding.");
|
||||
_updateSourcePath = bindingData.BindingExpression.ParentBinding.Path != null ? bindingData.BindingExpression.ParentBinding.Path.Path : null;
|
||||
#if FEATURE_VALIDATION
|
||||
bindingData.Element.BindingValidationError += new EventHandler<ValidationErrorEventArgs>(EditingElement_BindingValidationError);
|
||||
|
@ -6169,17 +6171,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
if (this.EditingRow == null || this.DataConnection.EndingEdit)
|
||||
{
|
||||
Debug.Assert(_editingColumnIndex == -1, "Expected _editingColumnIndex equal to -1.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex == -1, "Expected _editingColumnIndex equal to -1.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_editingColumnIndex != -1)
|
||||
{
|
||||
Debug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
Debug.Assert(this.EditingRow.Slot == this.CurrentSlot, "Expected EditingRow.Slot equals CurrentSlot.");
|
||||
Debug.Assert(_editingColumnIndex >= 0, "Expected positive _editingColumnIndex.");
|
||||
Debug.Assert(_editingColumnIndex < this.ColumnsItemsInternal.Count, "Expected _editingColumnIndex smaller than this.ColumnsItemsInternal.Count.");
|
||||
Debug.Assert(_editingColumnIndex == this.CurrentColumnIndex, "Expected _editingColumnIndex equals CurrentColumnIndex.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow.Slot == this.CurrentSlot, "Expected EditingRow.Slot equals CurrentSlot.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex >= 0, "Expected positive _editingColumnIndex.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex < this.ColumnsItemsInternal.Count, "Expected _editingColumnIndex smaller than this.ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex == this.CurrentColumnIndex, "Expected _editingColumnIndex equals CurrentColumnIndex.");
|
||||
|
||||
_editingColumnIndex = -1;
|
||||
this.EditingRow.Cells[this.CurrentColumnIndex].ApplyCellState(false /*animate*/);
|
||||
|
@ -6196,7 +6198,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
if (keepFocus)
|
||||
{
|
||||
bool success = Focus(FocusState.Programmatic);
|
||||
Debug.Assert(success, "Expected successful Focus call.");
|
||||
DiagnosticsDebug.Assert(success, "Expected successful Focus call.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6230,7 +6232,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
if (_collapsedSlotsTable.Contains(this.CurrentSlot) && this.CurrentSlot != this.SlotFromRowIndex(this.DataConnection.NewItemPlaceholderIndex))
|
||||
{
|
||||
DataGridRowGroupInfo rowGroupInfo = this.RowGroupHeadersTable.GetValueAt(this.RowGroupHeadersTable.GetPreviousIndex(this.CurrentSlot));
|
||||
Debug.Assert(rowGroupInfo != null, "Expected non-null rowGroupInfo.");
|
||||
DiagnosticsDebug.Assert(rowGroupInfo != null, "Expected non-null rowGroupInfo.");
|
||||
if (rowGroupInfo != null)
|
||||
{
|
||||
this.ExpandRowGroupParentChain(rowGroupInfo.Level, rowGroupInfo.Slot);
|
||||
|
@ -6290,13 +6292,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private bool FocusEditingCell(bool setFocus)
|
||||
{
|
||||
Debug.Assert(this.CurrentColumnIndex >= 0, "Expected positive CurrentColumnIndex.");
|
||||
Debug.Assert(this.CurrentColumnIndex < this.ColumnsItemsInternal.Count, "Expected CurrentColumnIndex smaller than ColumnsItemsInternal.Count.");
|
||||
Debug.Assert(this.CurrentSlot >= -1, "Expected CurrentSlot greater than or equal to -1.");
|
||||
Debug.Assert(this.CurrentSlot < this.SlotCount, "Expected CurrentSlot smaller than SlotCount.");
|
||||
Debug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
Debug.Assert(this.EditingRow.Slot == this.CurrentSlot, "Expected EditingRow.Slot equals CurrentSlot.");
|
||||
Debug.Assert(_editingColumnIndex != -1, "Expected _editingColumnIndex other than -1.");
|
||||
DiagnosticsDebug.Assert(this.CurrentColumnIndex >= 0, "Expected positive CurrentColumnIndex.");
|
||||
DiagnosticsDebug.Assert(this.CurrentColumnIndex < this.ColumnsItemsInternal.Count, "Expected CurrentColumnIndex smaller than ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(this.CurrentSlot >= -1, "Expected CurrentSlot greater than or equal to -1.");
|
||||
DiagnosticsDebug.Assert(this.CurrentSlot < this.SlotCount, "Expected CurrentSlot smaller than SlotCount.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow.Slot == this.CurrentSlot, "Expected EditingRow.Slot equals CurrentSlot.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex != -1, "Expected _editingColumnIndex other than -1.");
|
||||
|
||||
// TODO: Figure out if we should cache this.IsTabStop in order to restore
|
||||
// it later instead of setting it back to true unconditionally.
|
||||
|
@ -6567,8 +6569,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
if (this.RowGroupHeadersTable.Contains(slot))
|
||||
{
|
||||
Debug.Assert(slot >= 0, "Expected positive slot.");
|
||||
Debug.Assert(slot < this.SlotCount, "Expected slot smaller than this.SlotCount.");
|
||||
DiagnosticsDebug.Assert(slot >= 0, "Expected positive slot.");
|
||||
DiagnosticsDebug.Assert(slot < this.SlotCount, "Expected slot smaller than this.SlotCount.");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
|
@ -6659,7 +6661,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void NoIndicatorStateStoryboard_Completed(object sender, object e)
|
||||
{
|
||||
Debug.Assert(_hasNoIndicatorStateStoryboardCompletedHandler, "Expected _hasNoIndicatorStateStoryboardCompletedHandler is true.");
|
||||
DiagnosticsDebug.Assert(_hasNoIndicatorStateStoryboardCompletedHandler, "Expected _hasNoIndicatorStateStoryboardCompletedHandler is true.");
|
||||
|
||||
_showingMouseIndicators = false;
|
||||
}
|
||||
|
@ -6670,9 +6672,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
DataGridRow dataGridRow,
|
||||
DataGridCell dataGridCell)
|
||||
{
|
||||
Debug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
Debug.Assert(dataGridRow != null, "Expected non-null dataGridRow.");
|
||||
Debug.Assert(dataGridCell != null, "Expected non-null dataGridCell.");
|
||||
DiagnosticsDebug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
DiagnosticsDebug.Assert(dataGridRow != null, "Expected non-null dataGridRow.");
|
||||
DiagnosticsDebug.Assert(dataGridCell != null, "Expected non-null dataGridCell.");
|
||||
|
||||
FrameworkElement element = null;
|
||||
DataGridBoundColumn dataGridBoundColumn = dataGridColumn as DataGridBoundColumn;
|
||||
|
@ -6737,11 +6739,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return;
|
||||
}
|
||||
|
||||
Debug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
Debug.Assert(this.EditingRow.Slot == this.CurrentSlot, "Expected EditingRow.Slot equals CurrentSlot.");
|
||||
Debug.Assert(_editingColumnIndex >= 0, "Expected positive _editingColumnIndex.");
|
||||
Debug.Assert(_editingColumnIndex < this.ColumnsItemsInternal.Count, "Expected _editingColumnIndex smaller than this.ColumnsItemsInternal.Count.");
|
||||
Debug.Assert(_editingColumnIndex == this.CurrentColumnIndex, "Expected _editingColumnIndex equals CurrentColumnIndex.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow.Slot == this.CurrentSlot, "Expected EditingRow.Slot equals CurrentSlot.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex >= 0, "Expected positive _editingColumnIndex.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex < this.ColumnsItemsInternal.Count, "Expected _editingColumnIndex smaller than this.ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex == this.CurrentColumnIndex, "Expected _editingColumnIndex equals CurrentColumnIndex.");
|
||||
|
||||
FocusEditingCell(this.ContainsFocus || _focusEditingControl /*setFocus*/);
|
||||
|
||||
|
@ -6951,7 +6953,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return true;
|
||||
}
|
||||
|
||||
Debug.Assert(this.CurrentColumnIndex != -1, "Expected CurrentColumnIndex other than -1.");
|
||||
DiagnosticsDebug.Assert(this.CurrentColumnIndex != -1, "Expected CurrentColumnIndex other than -1.");
|
||||
desiredSlot = this.FirstVisibleSlot;
|
||||
columnIndex = this.CurrentColumnIndex;
|
||||
action = DataGridSelectionAction.SelectCurrent;
|
||||
|
@ -7300,7 +7302,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
desiredSlot = firstVisibleSlot;
|
||||
action = DataGridSelectionAction.SelectCurrent;
|
||||
Debug.Assert(_selectedItems.Count == 0, "Expected _selectedItems.Count equals 0.");
|
||||
DiagnosticsDebug.Assert(_selectedItems.Count == 0, "Expected _selectedItems.Count equals 0.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -7373,7 +7375,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
|
||||
int nextPageSlot = this.CurrentSlot == -1 ? this.DisplayData.FirstScrollingSlot : this.CurrentSlot;
|
||||
Debug.Assert(nextPageSlot != -1, "Expected nextPageSlot other than -1.");
|
||||
DiagnosticsDebug.Assert(nextPageSlot != -1, "Expected nextPageSlot other than -1.");
|
||||
int slot = GetNextVisibleSlot(nextPageSlot);
|
||||
|
||||
int scrollCount = this.DisplayData.NumTotallyDisplayedScrollingElements;
|
||||
|
@ -7427,7 +7429,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
|
||||
int previousPageSlot = (this.CurrentSlot == -1) ? this.DisplayData.FirstScrollingSlot : this.CurrentSlot;
|
||||
Debug.Assert(previousPageSlot != -1, "Expected previousPageSlot other than -1.");
|
||||
DiagnosticsDebug.Assert(previousPageSlot != -1, "Expected previousPageSlot other than -1.");
|
||||
|
||||
int scrollCount = this.DisplayData.NumTotallyDisplayedScrollingElements;
|
||||
int slot = GetPreviousVisibleSlot(previousPageSlot);
|
||||
|
@ -7438,7 +7440,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
slot = GetPreviousVisibleSlot(slot);
|
||||
}
|
||||
|
||||
Debug.Assert(previousPageSlot != -1, "Expected previousPageSlot other than -1.");
|
||||
DiagnosticsDebug.Assert(previousPageSlot != -1, "Expected previousPageSlot other than -1.");
|
||||
|
||||
_noSelectionChangeCount++;
|
||||
try
|
||||
|
@ -7679,8 +7681,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
|
||||
// Try to locate a writable cell before/after the current cell
|
||||
Debug.Assert(this.CurrentColumnIndex != -1, "Expected CurrentColumnIndex other than -1.");
|
||||
Debug.Assert(this.CurrentSlot != -1, "Expected CurrentSlot other than -1.");
|
||||
DiagnosticsDebug.Assert(this.CurrentColumnIndex != -1, "Expected CurrentColumnIndex other than -1.");
|
||||
DiagnosticsDebug.Assert(this.CurrentSlot != -1, "Expected CurrentSlot other than -1.");
|
||||
|
||||
int neighborVisibleWritableColumnIndex, neighborSlot;
|
||||
DataGridColumn dataGridColumn;
|
||||
|
@ -7732,12 +7734,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
targetSlot = neighborSlot;
|
||||
if (shift)
|
||||
{
|
||||
Debug.Assert(this.ColumnsInternal.LastVisibleWritableColumn != null, "Expected non-null ColumnsInternal.LastVisibleWritableColumn.");
|
||||
DiagnosticsDebug.Assert(this.ColumnsInternal.LastVisibleWritableColumn != null, "Expected non-null ColumnsInternal.LastVisibleWritableColumn.");
|
||||
targetColumnIndex = this.ColumnsInternal.LastVisibleWritableColumn.Index;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(this.ColumnsInternal.FirstVisibleWritableColumn != null, "Expected non-null ColumnsInternal.FirstVisibleWritableColumn.");
|
||||
DiagnosticsDebug.Assert(this.ColumnsInternal.FirstVisibleWritableColumn != null, "Expected non-null ColumnsInternal.FirstVisibleWritableColumn.");
|
||||
targetColumnIndex = this.ColumnsInternal.FirstVisibleWritableColumn.Index;
|
||||
}
|
||||
}
|
||||
|
@ -8020,17 +8022,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// columnIndex = -1, rowIndex = 2 --> Unexpected
|
||||
private bool SetCurrentCellCore(int columnIndex, int slot, bool commitEdit, bool endRowEdit)
|
||||
{
|
||||
Debug.Assert(columnIndex < this.ColumnsItemsInternal.Count, "Expected columnIndex smaller than ColumnsItemsInternal.Count.");
|
||||
Debug.Assert(slot < this.SlotCount, "Expected slot smaller than this.SlotCount.");
|
||||
Debug.Assert(columnIndex == -1 || this.ColumnsItemsInternal[columnIndex].IsVisible, "Expected columnIndex equals -1 or ColumnsItemsInternal[columnIndex].IsVisible is true.");
|
||||
Debug.Assert(columnIndex <= -1 || slot != -1, "Expected columnIndex smaller than or equal to -1 or slot other than -1.");
|
||||
DiagnosticsDebug.Assert(columnIndex < this.ColumnsItemsInternal.Count, "Expected columnIndex smaller than ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(slot < this.SlotCount, "Expected slot smaller than this.SlotCount.");
|
||||
DiagnosticsDebug.Assert(columnIndex == -1 || this.ColumnsItemsInternal[columnIndex].IsVisible, "Expected columnIndex equals -1 or ColumnsItemsInternal[columnIndex].IsVisible is true.");
|
||||
DiagnosticsDebug.Assert(columnIndex <= -1 || slot != -1, "Expected columnIndex smaller than or equal to -1 or slot other than -1.");
|
||||
|
||||
if (columnIndex == this.CurrentColumnIndex &&
|
||||
slot == this.CurrentSlot)
|
||||
{
|
||||
Debug.Assert(this.DataConnection != null, "Expected non-null DataConnection.");
|
||||
Debug.Assert(_editingColumnIndex == -1 || _editingColumnIndex == this.CurrentColumnIndex, "Expected _editingColumnIndex equals -1 or _editingColumnIndex equals CurrentColumnIndex.");
|
||||
Debug.Assert(this.EditingRow == null || this.EditingRow.Slot == this.CurrentSlot || this.DataConnection.EndingEdit, "Expected EditingRow is null or EditingRow.Slot equals CurrentSlot or DataConnection.EndingEdit is true.");
|
||||
DiagnosticsDebug.Assert(this.DataConnection != null, "Expected non-null DataConnection.");
|
||||
DiagnosticsDebug.Assert(_editingColumnIndex == -1 || _editingColumnIndex == this.CurrentColumnIndex, "Expected _editingColumnIndex equals -1 or _editingColumnIndex equals CurrentColumnIndex.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow == null || this.EditingRow.Slot == this.CurrentSlot || this.DataConnection.EndingEdit, "Expected EditingRow is null or EditingRow.Slot equals CurrentSlot or DataConnection.EndingEdit is true.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -8049,8 +8051,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
if (this.CurrentColumnIndex > -1)
|
||||
{
|
||||
Debug.Assert(this.CurrentColumnIndex < this.ColumnsItemsInternal.Count, "Expected CurrentColumnIndex smaller than ColumnsItemsInternal.Count.");
|
||||
Debug.Assert(this.CurrentSlot < this.SlotCount, "Expected CurrentSlot smaller than SlotCount.");
|
||||
DiagnosticsDebug.Assert(this.CurrentColumnIndex < this.ColumnsItemsInternal.Count, "Expected CurrentColumnIndex smaller than ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(this.CurrentSlot < this.SlotCount, "Expected CurrentSlot smaller than SlotCount.");
|
||||
|
||||
if (!IsInnerCellOutOfBounds(oldCurrentCell.ColumnIndex, oldCurrentCell.Slot) &&
|
||||
this.IsSlotVisible(oldCurrentCell.Slot))
|
||||
|
@ -8135,9 +8137,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
if (this.CurrentColumnIndex > -1)
|
||||
{
|
||||
Debug.Assert(this.CurrentSlot > -1, "Expected CurrentSlot greater than -1.");
|
||||
Debug.Assert(this.CurrentColumnIndex < this.ColumnsItemsInternal.Count, "Expected CurrentColumnIndex smaller than ColumnsItemsInternal.Count.");
|
||||
Debug.Assert(this.CurrentSlot < this.SlotCount, "Expected CurrentSlot smaller than SlotCount.");
|
||||
DiagnosticsDebug.Assert(this.CurrentSlot > -1, "Expected CurrentSlot greater than -1.");
|
||||
DiagnosticsDebug.Assert(this.CurrentColumnIndex < this.ColumnsItemsInternal.Count, "Expected CurrentColumnIndex smaller than ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(this.CurrentSlot < this.SlotCount, "Expected CurrentSlot smaller than SlotCount.");
|
||||
if (this.IsSlotVisible(this.CurrentSlot))
|
||||
{
|
||||
UpdateCurrentState(this.DisplayData.GetDisplayedElement(this.CurrentSlot), this.CurrentColumnIndex, true /*applyCellState*/);
|
||||
|
@ -8418,13 +8420,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
// maximum travel distance -- not the total width
|
||||
_hScrollBar.Maximum = totalVisibleWidth - cellsWidth;
|
||||
Debug.Assert(totalVisibleFrozenWidth >= 0, "Expected positive totalVisibleFrozenWidth.");
|
||||
DiagnosticsDebug.Assert(totalVisibleFrozenWidth >= 0, "Expected positive totalVisibleFrozenWidth.");
|
||||
if (_frozenColumnScrollBarSpacer != null)
|
||||
{
|
||||
_frozenColumnScrollBarSpacer.Width = totalVisibleFrozenWidth;
|
||||
}
|
||||
|
||||
Debug.Assert(_hScrollBar.Maximum >= 0, "Expected positive _hScrollBar.Maximum.");
|
||||
DiagnosticsDebug.Assert(_hScrollBar.Maximum >= 0, "Expected positive _hScrollBar.Maximum.");
|
||||
|
||||
// width of the scrollable viewing area
|
||||
double viewPortSize = Math.Max(0, cellsWidth - totalVisibleFrozenWidth);
|
||||
|
@ -8607,7 +8609,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
bool beginEdit;
|
||||
|
||||
Debug.Assert(slot >= 0, "Expected positive slot.");
|
||||
DiagnosticsDebug.Assert(slot >= 0, "Expected positive slot.");
|
||||
|
||||
// Before changing selection, check if the current cell needs to be committed, and
|
||||
// check if the current row needs to be committed. If any of those two operations are required and fail,
|
||||
|
@ -8696,7 +8698,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
private void UpdateValidationResults(List<ValidationResult> newValidationResults, bool scrollIntoView)
|
||||
{
|
||||
bool validationResultsChanged = false;
|
||||
Debug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
|
||||
// Remove the validation results that have been fixed
|
||||
List<ValidationResult> removedValidationResults = new List<ValidationResult>();
|
||||
|
@ -8791,7 +8793,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
bool isCellValid = true;
|
||||
|
||||
Debug.Assert(cell.OwningColumn != null, "Expected cell has owning column.");
|
||||
DiagnosticsDebug.Assert(cell.OwningColumn != null, "Expected cell has owning column.");
|
||||
if (!cell.OwningColumn.IsReadOnly)
|
||||
{
|
||||
foreach (ValidationResult validationResult in _validationResults)
|
||||
|
@ -8864,7 +8866,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
// maximum travel distance -- not the total height
|
||||
_vScrollBar.Maximum = totalVisibleHeight - cellsHeight;
|
||||
Debug.Assert(_vScrollBar.Maximum >= 0, "Expected positive _vScrollBar.Maximum.");
|
||||
DiagnosticsDebug.Assert(_vScrollBar.Maximum >= 0, "Expected positive _vScrollBar.Maximum.");
|
||||
|
||||
// total height of the display area
|
||||
_vScrollBar.ViewportSize = cellsHeight;
|
||||
|
@ -8937,7 +8939,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
if (this.EditingRow != null)
|
||||
{
|
||||
object dataItem = this.EditingRow.DataContext;
|
||||
Debug.Assert(dataItem != null, "Expected non-null dataItem.");
|
||||
DiagnosticsDebug.Assert(dataItem != null, "Expected non-null dataItem.");
|
||||
|
||||
if (!_initializingNewItem)
|
||||
{
|
||||
|
@ -9047,7 +9049,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
string errorString = null;
|
||||
if (string.IsNullOrEmpty(bindingProperty))
|
||||
{
|
||||
Debug.Assert(string.IsNullOrEmpty(bindingPath));
|
||||
DiagnosticsDebug.Assert(string.IsNullOrEmpty(bindingPath));
|
||||
ValidationUtil.CatchNonCriticalExceptions(() => { errorString = idei.Error; });
|
||||
if (!string.IsNullOrEmpty(errorString))
|
||||
{
|
||||
|
@ -9104,7 +9106,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(string.IsNullOrEmpty(bindingPath), "Expected bindingPath is null or empty.");
|
||||
DiagnosticsDebug.Assert(string.IsNullOrEmpty(bindingPath), "Expected bindingPath is null or empty.");
|
||||
validationResult = new ValidationResult(errorString);
|
||||
}
|
||||
|
||||
|
@ -9134,7 +9136,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
INotifyDataErrorInfo indei = sender as INotifyDataErrorInfo;
|
||||
if (_validationItems.ContainsKey(indei))
|
||||
{
|
||||
Debug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow != null, "Expected non-null EditingRow.");
|
||||
|
||||
// Determine the binding path.
|
||||
string bindingPath = _validationItems[indei];
|
||||
|
|
|
@ -14,6 +14,8 @@ using Windows.UI.Xaml.Controls;
|
|||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -128,7 +130,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
get
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null && this.OwningColumn != null && this.OwningRow != null, "Expected non-null owning DataGrid, DataGridColumn and DataGridRow.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null && this.OwningColumn != null && this.OwningRow != null, "Expected non-null owning DataGrid, DataGridColumn and DataGridRow.");
|
||||
|
||||
return this.OwningGrid.CurrentColumnIndex == this.OwningColumn.Index &&
|
||||
this.OwningGrid.CurrentSlot == this.OwningRow.Slot;
|
||||
|
@ -211,7 +213,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
get
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
|
||||
return this.OwningGrid.EditingRow == this.OwningRow &&
|
||||
this.OwningGrid.EditingColumnIndex == this.ColumnIndex;
|
||||
|
@ -444,13 +446,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
if (!e.Handled && this.OwningGrid.IsTabStop)
|
||||
{
|
||||
bool success = this.OwningGrid.Focus(FocusState.Programmatic);
|
||||
Debug.Assert(success, "Expected successful focus change.");
|
||||
DiagnosticsDebug.Assert(success, "Expected successful focus change.");
|
||||
}
|
||||
|
||||
if (this.OwningRow != null)
|
||||
{
|
||||
Debug.Assert(sender is DataGridCell, "Expected sender is DataGridCell.");
|
||||
Debug.Assert(sender == this, "Expected sender is this.");
|
||||
DiagnosticsDebug.Assert(sender is DataGridCell, "Expected sender is DataGridCell.");
|
||||
DiagnosticsDebug.Assert(sender == this, "Expected sender is this.");
|
||||
e.Handled = this.OwningGrid.UpdateStateOnTapped(e, this.ColumnIndex, this.OwningRow.Slot, !e.Handled /*allowEdit*/);
|
||||
this.OwningGrid.UpdatedStateOnTapped = true;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ using Windows.UI.Xaml;
|
|||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -79,8 +81,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
foreach (DataGridColumn column in this.OwningGrid.ColumnsInternal.GetVisibleColumns())
|
||||
{
|
||||
DataGridCell cell = this.OwningRow.Cells[column.Index];
|
||||
Debug.Assert(cell.OwningColumn == column, "Expected column owner.");
|
||||
Debug.Assert(column.IsVisible, "Expected visible column.");
|
||||
DiagnosticsDebug.Assert(cell.OwningColumn == column, "Expected column owner.");
|
||||
DiagnosticsDebug.Assert(column.IsVisible, "Expected visible column.");
|
||||
|
||||
if (column.IsFrozen)
|
||||
{
|
||||
|
@ -318,9 +320,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
|
||||
private bool ShouldDisplayCell(DataGridColumn column, double frozenLeftEdge, double scrollingLeftEdge)
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
Debug.Assert(this.OwningGrid.HorizontalAdjustment >= 0, "Expected owning positive DataGrid.HorizontalAdjustment.");
|
||||
Debug.Assert(this.OwningGrid.HorizontalAdjustment <= this.OwningGrid.HorizontalOffset, "Expected owning DataGrid.HorizontalAdjustment smaller than or equal to DataGrid.HorizontalOffset.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid.HorizontalAdjustment >= 0, "Expected owning positive DataGrid.HorizontalAdjustment.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid.HorizontalAdjustment <= this.OwningGrid.HorizontalOffset, "Expected owning DataGrid.HorizontalAdjustment smaller than or equal to DataGrid.HorizontalOffset.");
|
||||
|
||||
if (column.Visibility != Visibility.Visible)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,8 @@ using Windows.UI.Xaml.Controls;
|
|||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -730,8 +732,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
set
|
||||
{
|
||||
Debug.Assert(value >= -1, "Expected value >= -1.");
|
||||
Debug.Assert(value < int.MaxValue, "Expected value < int.MaxValue.");
|
||||
DiagnosticsDebug.Assert(value >= -1, "Expected value >= -1.");
|
||||
DiagnosticsDebug.Assert(value < int.MaxValue, "Expected value < int.MaxValue.");
|
||||
|
||||
_displayIndexWithFiller = value;
|
||||
}
|
||||
|
@ -851,8 +853,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
if (dataGridRow.OwningGrid == this.OwningGrid)
|
||||
{
|
||||
Debug.Assert(this.Index >= 0, "Expected positive Index.");
|
||||
Debug.Assert(this.Index < this.OwningGrid.ColumnsItemsInternal.Count, "Expected smaller Index.");
|
||||
DiagnosticsDebug.Assert(this.Index >= 0, "Expected positive Index.");
|
||||
DiagnosticsDebug.Assert(this.Index < this.OwningGrid.ColumnsItemsInternal.Count, "Expected smaller Index.");
|
||||
|
||||
DataGridCell dataGridCell = dataGridRow.Cells[this.Index];
|
||||
if (dataGridCell != null)
|
||||
|
@ -881,8 +883,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
throw DataGridError.DataGrid.NoOwningGrid(this.GetType());
|
||||
}
|
||||
|
||||
Debug.Assert(this.Index >= 0, "Expected positive Index.");
|
||||
Debug.Assert(this.Index < this.OwningGrid.ColumnsItemsInternal.Count, "Expected smaller Index.");
|
||||
DiagnosticsDebug.Assert(this.Index >= 0, "Expected positive Index.");
|
||||
DiagnosticsDebug.Assert(this.Index < this.OwningGrid.ColumnsItemsInternal.Count, "Expected smaller Index.");
|
||||
|
||||
DataGridRow dataGridRow = this.OwningGrid.GetRowFromItem(dataItem);
|
||||
if (dataGridRow == null)
|
||||
|
@ -1096,7 +1098,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
if (_inputBindings != null)
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
|
||||
// Use the editing bindings if they've already been created
|
||||
bindings = _inputBindings;
|
||||
|
@ -1195,7 +1197,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <returns>The resultant cell value.</returns>
|
||||
internal object GetCellValue(object item, Binding binding)
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
|
||||
object content = null;
|
||||
if (binding != null)
|
||||
|
@ -1281,7 +1283,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <param name="userInitiated">Whether or not this resize was initiated by a user action.</param>
|
||||
internal void Resize(double value, DataGridLengthUnitType unitType, double desiredValue, double displayValue, bool userInitiated)
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
|
||||
double newValue = value;
|
||||
double newDesiredValue = desiredValue;
|
||||
|
@ -1408,7 +1410,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <param name="value">The new star value.</param>
|
||||
internal void SetWidthStarValue(double value)
|
||||
{
|
||||
Debug.Assert(this.Width.IsStar, "Expected Width.IsStar.");
|
||||
DiagnosticsDebug.Assert(this.Width.IsStar, "Expected Width.IsStar.");
|
||||
|
||||
this.InheritsWidth = false;
|
||||
SetWidthInternalNoCallback(new DataGridLength(value, this.Width.UnitType, this.Width.DesiredValue, this.Width.DisplayValue));
|
||||
|
|
|
@ -20,6 +20,8 @@ using Windows.UI.Xaml.Controls.Primitives;
|
|||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -304,7 +306,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
|
||||
internal void InvokeProcessSort()
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
|
||||
if (this.OwningGrid.WaitForLostFocus(() => { this.InvokeProcessSort(); }))
|
||||
{
|
||||
|
@ -346,7 +348,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
|
||||
SortDescription? sort = this.OwningColumn.GetSortDescription();
|
||||
ICollectionView collectionView = owningGrid.DataConnection.CollectionView;
|
||||
Debug.Assert(collectionView != null);
|
||||
DiagnosticsDebug.Assert(collectionView != null);
|
||||
try
|
||||
{
|
||||
owningGrid.OnUserSorting();
|
||||
|
@ -485,7 +487,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
{
|
||||
DataGridColumnHeaderInteractionInfo interactionInfo = this.OwningGrid.ColumnHeaderInteractionInfo;
|
||||
|
||||
Debug.Assert(interactionInfo.DragMode != DragMode.None, "Expected _dragMode other than None.");
|
||||
DiagnosticsDebug.Assert(interactionInfo.DragMode != DragMode.None, "Expected _dragMode other than None.");
|
||||
|
||||
interactionInfo.DragColumn = column;
|
||||
interactionInfo.DragMode = DragMode.Resize;
|
||||
|
@ -616,7 +618,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
return;
|
||||
}
|
||||
|
||||
Debug.Assert(interactionInfo.DragPointerId == 0, "Expected _dragPointerId is 0.");
|
||||
DiagnosticsDebug.Assert(interactionInfo.DragPointerId == 0, "Expected _dragPointerId is 0.");
|
||||
|
||||
bool handled = e.Handled;
|
||||
|
||||
|
@ -635,8 +637,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
interactionInfo.CapturedPointer = null;
|
||||
}
|
||||
|
||||
Debug.Assert(interactionInfo.DragMode == DragMode.None, "Expected _dragMode equals None.");
|
||||
Debug.Assert(interactionInfo.DragColumn == null, "Expected _dragColumn is null.");
|
||||
DiagnosticsDebug.Assert(interactionInfo.DragMode == DragMode.None, "Expected _dragMode equals None.");
|
||||
DiagnosticsDebug.Assert(interactionInfo.DragColumn == null, "Expected _dragColumn is null.");
|
||||
interactionInfo.DragMode = DragMode.PointerPressed;
|
||||
interactionInfo.DragPointerId = e.Pointer.PointerId;
|
||||
interactionInfo.FrozenColumnsWidth = this.OwningGrid.ColumnsInternal.GetVisibleFrozenEdgedColumnsWidth();
|
||||
|
@ -775,7 +777,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
Point pointerPositionHeaders = e.GetCurrentPoint(this.OwningGrid.ColumnHeaders).Position;
|
||||
bool handled = false;
|
||||
|
||||
Debug.Assert(this.OwningGrid.Parent is UIElement, "Expected owning DataGrid's parent to be a UIElement.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid.Parent is UIElement, "Expected owning DataGrid's parent to be a UIElement.");
|
||||
|
||||
double distanceFromLeft = pointerPosition.X;
|
||||
double distanceFromRight = this.ActualWidth - distanceFromLeft;
|
||||
|
@ -820,7 +822,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
/// <returns>The column against whose top-left the reordering caret should be positioned.</returns>
|
||||
private DataGridColumn GetReorderingTargetColumn(Point pointerPositionHeaders, bool scroll, out double scrollAmount)
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");
|
||||
|
||||
scrollAmount = 0;
|
||||
double leftEdge = 0;
|
||||
|
@ -894,7 +896,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
/// <returns>The display index to set the column to.</returns>
|
||||
private int GetReorderingTargetDisplayIndex(Point pointerPositionHeaders)
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");
|
||||
|
||||
DataGridColumn targetColumn = GetReorderingTargetColumn(pointerPositionHeaders, false /*scroll*/, out _);
|
||||
if (targetColumn != null)
|
||||
|
@ -909,7 +911,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
|
||||
private void OnPointerMove_BeginReorder(uint pointerId, Point pointerPosition)
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");
|
||||
|
||||
DataGridColumnHeader dragIndicator = new DataGridColumnHeader();
|
||||
dragIndicator.OwningColumn = this.OwningColumn;
|
||||
|
@ -957,7 +959,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
|
||||
// The app didn't cancel, so prepare for the reorder.
|
||||
interactionInfo.DragColumn = this.OwningColumn;
|
||||
Debug.Assert(interactionInfo.DragMode != DragMode.None, "Expected _dragMode other than None.");
|
||||
DiagnosticsDebug.Assert(interactionInfo.DragMode != DragMode.None, "Expected _dragMode other than None.");
|
||||
interactionInfo.DragMode = DragMode.Reorder;
|
||||
interactionInfo.DragPointerId = pointerId;
|
||||
interactionInfo.DragStart = pointerPosition;
|
||||
|
@ -970,7 +972,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
|
||||
private void OnPointerMove_Reorder(ref bool handled, Pointer pointer, Point pointerPosition, Point pointerPositionHeaders, double distanceFromLeft, double distanceFromRight)
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");
|
||||
|
||||
if (handled)
|
||||
{
|
||||
|
@ -1035,13 +1037,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
|
||||
private void OnPointerMove_Resize(ref bool handled, Point pointerPositionHeaders)
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");
|
||||
|
||||
DataGridColumnHeaderInteractionInfo interactionInfo = this.OwningGrid.ColumnHeaderInteractionInfo;
|
||||
|
||||
if (!handled && interactionInfo.DragMode == DragMode.Resize && interactionInfo.DragColumn != null && interactionInfo.DragStart.HasValue)
|
||||
{
|
||||
Debug.Assert(interactionInfo.ResizePointerId != 0, "Expected interactionInfo.ResizePointerId other than 0.");
|
||||
DiagnosticsDebug.Assert(interactionInfo.ResizePointerId != 0, "Expected interactionInfo.ResizePointerId other than 0.");
|
||||
|
||||
// Resize column
|
||||
double pointerDelta = pointerPositionHeaders.X - interactionInfo.DragStart.Value.X;
|
||||
|
@ -1058,13 +1060,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
|
||||
private void SetOriginalCursor()
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");
|
||||
|
||||
DataGridColumnHeaderInteractionInfo interactionInfo = this.OwningGrid.ColumnHeaderInteractionInfo;
|
||||
|
||||
if (interactionInfo.ResizePointerId != 0)
|
||||
{
|
||||
Debug.Assert(interactionInfo.OriginalCursor != null, "Expected non-null interactionInfo.OriginalCursor.");
|
||||
DiagnosticsDebug.Assert(interactionInfo.OriginalCursor != null, "Expected non-null interactionInfo.OriginalCursor.");
|
||||
|
||||
Window.Current.CoreWindow.PointerCursor = interactionInfo.OriginalCursor;
|
||||
interactionInfo.ResizePointerId = 0;
|
||||
|
@ -1073,7 +1075,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
|
||||
private void SetResizeCursor(Pointer pointer, Point pointerPosition)
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");
|
||||
|
||||
DataGridColumnHeaderInteractionInfo interactionInfo = this.OwningGrid.ColumnHeaderInteractionInfo;
|
||||
|
||||
|
|
|
@ -11,6 +11,8 @@ using Windows.UI.Xaml.Automation.Peers;
|
|||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -143,7 +145,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
foreach (DataGridColumn dataGridColumn in this.OwningGrid.ColumnsInternal.GetVisibleColumns())
|
||||
{
|
||||
DataGridColumnHeader columnHeader = dataGridColumn.HeaderCell;
|
||||
Debug.Assert(columnHeader.OwningColumn == dataGridColumn, "Expected columnHeader owned by dataGridColumn.");
|
||||
DiagnosticsDebug.Assert(columnHeader.OwningColumn == dataGridColumn, "Expected columnHeader owned by dataGridColumn.");
|
||||
|
||||
if (dataGridColumn.IsFrozen)
|
||||
{
|
||||
|
@ -382,7 +384,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
DataGridFillerColumn fillerColumn = this.OwningGrid.ColumnsInternal.FillerColumn;
|
||||
if (!fillerColumn.IsRepresented)
|
||||
{
|
||||
Debug.Assert(!this.Children.Contains(fillerColumn.HeaderCell), "Unexpected parent for filler column header cell.");
|
||||
DiagnosticsDebug.Assert(!this.Children.Contains(fillerColumn.HeaderCell), "Unexpected parent for filler column header cell.");
|
||||
fillerColumn.HeaderCell.SeparatorVisibility = Visibility.Collapsed;
|
||||
this.Children.Insert(this.OwningGrid.ColumnsInternal.Count, fillerColumn.HeaderCell);
|
||||
fillerColumn.IsRepresented = true;
|
||||
|
|
|
@ -15,6 +15,8 @@ using Windows.UI.Xaml;
|
|||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -63,7 +65,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// Returns the column's width
|
||||
internal static double GetEdgedColumnWidth(DataGridColumn dataGridColumn)
|
||||
{
|
||||
Debug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
DiagnosticsDebug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
return dataGridColumn.ActualWidth;
|
||||
}
|
||||
|
||||
|
@ -100,7 +102,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <param name="desiredWidth">The new desired width of the column.</param>
|
||||
internal void AutoSizeColumn(DataGridColumn column, double desiredWidth)
|
||||
{
|
||||
Debug.Assert(
|
||||
DiagnosticsDebug.Assert(
|
||||
column.Width.IsAuto || column.Width.IsSizeToCells || column.Width.IsSizeToHeader || (!this.UsesStarSizing && column.Width.IsStar),
|
||||
"Expected column.Width.IsAuto or column.Width.IsSizeToCells or column.Width.IsSizeToHeader or (!UsesStarSizing && column.Width.IsStar).");
|
||||
|
||||
|
@ -170,7 +172,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal bool GetColumnReadOnlyState(DataGridColumn dataGridColumn, bool isReadOnly)
|
||||
{
|
||||
Debug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
DiagnosticsDebug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
|
||||
DataGridBoundColumn dataGridBoundColumn = dataGridColumn as DataGridBoundColumn;
|
||||
if (dataGridBoundColumn != null && dataGridBoundColumn.Binding != null)
|
||||
|
@ -285,7 +287,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal void OnColumnDisplayIndexChanged(DataGridColumn dataGridColumn)
|
||||
{
|
||||
Debug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
DiagnosticsDebug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
DataGridColumnEventArgs e = new DataGridColumnEventArgs(dataGridColumn);
|
||||
|
||||
// Call protected method to raise event
|
||||
|
@ -310,8 +312,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal void OnColumnDisplayIndexChanging(DataGridColumn targetColumn, int newDisplayIndex)
|
||||
{
|
||||
Debug.Assert(targetColumn != null, "Expected non-null targetColumn.");
|
||||
Debug.Assert(newDisplayIndex != targetColumn.DisplayIndexWithFiller, "Expected newDisplayIndex other than targetColumn.DisplayIndexWithFiller.");
|
||||
DiagnosticsDebug.Assert(targetColumn != null, "Expected non-null targetColumn.");
|
||||
DiagnosticsDebug.Assert(newDisplayIndex != targetColumn.DisplayIndexWithFiller, "Expected newDisplayIndex other than targetColumn.DisplayIndexWithFiller.");
|
||||
|
||||
if (InDisplayIndexAdjustments)
|
||||
{
|
||||
|
@ -430,7 +432,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <param name="oldValue">The old ActualMaxWidth of the column.</param>
|
||||
internal void OnColumnMaxWidthChanged(DataGridColumn column, double oldValue)
|
||||
{
|
||||
Debug.Assert(column != null, "Expected non-null column.");
|
||||
DiagnosticsDebug.Assert(column != null, "Expected non-null column.");
|
||||
|
||||
if (column.Visibility == Visibility.Visible && oldValue != column.ActualMaxWidth)
|
||||
{
|
||||
|
@ -460,7 +462,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <param name="oldValue">The old ActualMinWidth of the column.</param>
|
||||
internal void OnColumnMinWidthChanged(DataGridColumn column, double oldValue)
|
||||
{
|
||||
Debug.Assert(column != null, "Expected non-null column.");
|
||||
DiagnosticsDebug.Assert(column != null, "Expected non-null column.");
|
||||
|
||||
if (column.Visibility == Visibility.Visible && oldValue != column.ActualMinWidth)
|
||||
{
|
||||
|
@ -485,7 +487,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal void OnColumnReadOnlyStateChanging(DataGridColumn dataGridColumn, bool isReadOnly)
|
||||
{
|
||||
Debug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
DiagnosticsDebug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
if (isReadOnly && this.CurrentColumnIndex == dataGridColumn.Index)
|
||||
{
|
||||
// Edited column becomes read-only. Exit editing mode.
|
||||
|
@ -498,7 +500,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal void OnColumnVisibleStateChanged(DataGridColumn updatedColumn)
|
||||
{
|
||||
Debug.Assert(updatedColumn != null, "Expected non-null updatedColumn.");
|
||||
DiagnosticsDebug.Assert(updatedColumn != null, "Expected non-null updatedColumn.");
|
||||
|
||||
CorrectColumnFrozenStates();
|
||||
UpdateDisplayedColumns();
|
||||
|
@ -509,7 +511,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
if (updatedColumn.IsVisible &&
|
||||
this.ColumnsInternal.VisibleColumnCount == 1 && this.CurrentColumnIndex == -1)
|
||||
{
|
||||
Debug.Assert(this.SelectedIndex == this.DataConnection.IndexOf(this.SelectedItem), "Expected SelectedIndex equals DataConnection.IndexOf(this.SelectedItem).");
|
||||
DiagnosticsDebug.Assert(this.SelectedIndex == this.DataConnection.IndexOf(this.SelectedItem), "Expected SelectedIndex equals DataConnection.IndexOf(this.SelectedItem).");
|
||||
if (this.SelectedIndex != -1)
|
||||
{
|
||||
SetAndSelectCurrentCell(updatedColumn.Index, this.SelectedIndex, true /*forceCurrentCellSelection*/);
|
||||
|
@ -533,7 +535,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal void OnColumnVisibleStateChanging(DataGridColumn targetColumn)
|
||||
{
|
||||
Debug.Assert(targetColumn != null, "Expected non-null targetColumn.");
|
||||
DiagnosticsDebug.Assert(targetColumn != null, "Expected non-null targetColumn.");
|
||||
|
||||
if (targetColumn.IsVisible && this.CurrentColumn == targetColumn)
|
||||
{
|
||||
|
@ -557,7 +559,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal void OnColumnWidthChanged(DataGridColumn updatedColumn)
|
||||
{
|
||||
Debug.Assert(updatedColumn != null, "Expected non-null updatedColumn.");
|
||||
DiagnosticsDebug.Assert(updatedColumn != null, "Expected non-null updatedColumn.");
|
||||
if (updatedColumn.IsVisible)
|
||||
{
|
||||
EnsureHorizontalLayout();
|
||||
|
@ -583,7 +585,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// Update current cell if needed
|
||||
if (newCurrentCellCoordinates.ColumnIndex != -1)
|
||||
{
|
||||
Debug.Assert(this.CurrentColumnIndex == -1, "Expected CurrentColumnIndex equals -1.");
|
||||
DiagnosticsDebug.Assert(this.CurrentColumnIndex == -1, "Expected CurrentColumnIndex equals -1.");
|
||||
SetAndSelectCurrentCell(
|
||||
newCurrentCellCoordinates.ColumnIndex,
|
||||
newCurrentCellCoordinates.Slot,
|
||||
|
@ -601,9 +603,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// Fix the Index of all following columns
|
||||
CorrectColumnIndexesAfterInsertion(insertedColumn, 1);
|
||||
|
||||
Debug.Assert(insertedColumn.Index >= 0, "Expected positive insertedColumn.Index.");
|
||||
Debug.Assert(insertedColumn.Index < this.ColumnsItemsInternal.Count, "insertedColumn.Index smaller than ColumnsItemsInternal.Count.");
|
||||
Debug.Assert(insertedColumn.OwningGrid == this, "Expected insertedColumn.OwningGrid equals this DataGrid.");
|
||||
DiagnosticsDebug.Assert(insertedColumn.Index >= 0, "Expected positive insertedColumn.Index.");
|
||||
DiagnosticsDebug.Assert(insertedColumn.Index < this.ColumnsItemsInternal.Count, "insertedColumn.Index smaller than ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(insertedColumn.OwningGrid == this, "Expected insertedColumn.OwningGrid equals this DataGrid.");
|
||||
|
||||
CorrectColumnDisplayIndexesAfterInsertion(insertedColumn);
|
||||
|
||||
|
@ -638,7 +640,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
internal DataGridCellCoordinates OnInsertingColumn(int columnIndexInserted, DataGridColumn insertColumn)
|
||||
{
|
||||
DataGridCellCoordinates newCurrentCellCoordinates;
|
||||
Debug.Assert(insertColumn != null, "Expected non-null insertColumn.");
|
||||
DiagnosticsDebug.Assert(insertColumn != null, "Expected non-null insertColumn.");
|
||||
|
||||
if (insertColumn.OwningGrid != null && insertColumn != this.ColumnsInternal.RowGroupSpacerColumn)
|
||||
{
|
||||
|
@ -667,15 +669,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// Update current cell if needed
|
||||
if (newCurrentCellCoordinates.ColumnIndex != -1)
|
||||
{
|
||||
Debug.Assert(this.CurrentColumnIndex == -1, "Expected CurrentColumnIndex equals -1.");
|
||||
DiagnosticsDebug.Assert(this.CurrentColumnIndex == -1, "Expected CurrentColumnIndex equals -1.");
|
||||
SetAndSelectCurrentCell(newCurrentCellCoordinates.ColumnIndex, newCurrentCellCoordinates.Slot, false /*forceCurrentCellSelection*/);
|
||||
}
|
||||
}
|
||||
|
||||
internal void OnRemovedColumn_PreNotification(DataGridColumn removedColumn)
|
||||
{
|
||||
Debug.Assert(removedColumn.Index >= 0, "Expected positive removedColumn.Index.");
|
||||
Debug.Assert(removedColumn.OwningGrid == null, "Expected null removedColumn.OwningGrid.");
|
||||
DiagnosticsDebug.Assert(removedColumn.Index >= 0, "Expected positive removedColumn.Index.");
|
||||
DiagnosticsDebug.Assert(removedColumn.OwningGrid == null, "Expected null removedColumn.OwningGrid.");
|
||||
|
||||
// Intentionally keep the DisplayIndex intact after detaching the column.
|
||||
CorrectColumnIndexesAfterDeletion(removedColumn);
|
||||
|
@ -712,9 +714,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal DataGridCellCoordinates OnRemovingColumn(DataGridColumn dataGridColumn)
|
||||
{
|
||||
Debug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
Debug.Assert(dataGridColumn.Index >= 0, "Expected positive dataGridColumn.Index.");
|
||||
Debug.Assert(dataGridColumn.Index < this.ColumnsItemsInternal.Count, "Expected dataGridColumn.Index smaller than ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
DiagnosticsDebug.Assert(dataGridColumn.Index >= 0, "Expected positive dataGridColumn.Index.");
|
||||
DiagnosticsDebug.Assert(dataGridColumn.Index < this.ColumnsItemsInternal.Count, "Expected dataGridColumn.Index smaller than ColumnsItemsInternal.Count.");
|
||||
|
||||
DataGridCellCoordinates newCurrentCellCoordinates;
|
||||
|
||||
|
@ -781,7 +783,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
|
||||
bool success = this.SetCurrentCellCore(-1, -1);
|
||||
Debug.Assert(success, "Expected successful call to SetCurrentCellCore.");
|
||||
DiagnosticsDebug.Assert(success, "Expected successful call to SetCurrentCellCore.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -809,7 +811,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
else if (!this.ColumnsInternal.DisplayInOrder(this.DisplayData.FirstDisplayedScrollingCol, dataGridColumn.Index))
|
||||
{
|
||||
// Deleted column is displayed before first scrolling column
|
||||
Debug.Assert(_horizontalOffset >= GetEdgedColumnWidth(dataGridColumn), "Expected _horizontalOffset greater than or equal to GetEdgedColumnWidth(dataGridColumn).");
|
||||
DiagnosticsDebug.Assert(_horizontalOffset >= GetEdgedColumnWidth(dataGridColumn), "Expected _horizontalOffset greater than or equal to GetEdgedColumnWidth(dataGridColumn).");
|
||||
_horizontalOffset -= GetEdgedColumnWidth(dataGridColumn);
|
||||
}
|
||||
|
||||
|
@ -827,13 +829,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// </summary>
|
||||
internal void RefreshColumnElements(DataGridColumn dataGridColumn, string propertyName)
|
||||
{
|
||||
Debug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
DiagnosticsDebug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
|
||||
// Take care of the non-displayed loaded rows
|
||||
for (int index = 0; index < _loadedRows.Count;)
|
||||
{
|
||||
DataGridRow dataGridRow = _loadedRows[index];
|
||||
Debug.Assert(dataGridRow != null, "Expected non-null dataGridRow.");
|
||||
DiagnosticsDebug.Assert(dataGridRow != null, "Expected non-null dataGridRow.");
|
||||
if (!this.IsSlotVisible(dataGridRow.Slot))
|
||||
{
|
||||
RefreshCellElement(dataGridColumn, dataGridRow, propertyName);
|
||||
|
@ -867,8 +869,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <returns>The remaining amount of adjustment.</returns>
|
||||
private static double DecreaseNonStarColumnWidth(DataGridColumn column, double targetWidth, double amount)
|
||||
{
|
||||
Debug.Assert(amount < 0, "Expected negative amount.");
|
||||
Debug.Assert(column.Width.UnitType != DataGridLengthUnitType.Star, "column.Width.UnitType other than DataGridLengthUnitType.Star.");
|
||||
DiagnosticsDebug.Assert(amount < 0, "Expected negative amount.");
|
||||
DiagnosticsDebug.Assert(column.Width.UnitType != DataGridLengthUnitType.Star, "column.Width.UnitType other than DataGridLengthUnitType.Star.");
|
||||
|
||||
if (DoubleUtil.GreaterThanOrClose(targetWidth, column.Width.DisplayValue))
|
||||
{
|
||||
|
@ -897,7 +899,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private static DataGridBoundColumn GetDataGridColumnFromType(Type type)
|
||||
{
|
||||
Debug.Assert(type != null, "Expected non-null type.");
|
||||
DiagnosticsDebug.Assert(type != null, "Expected non-null type.");
|
||||
if (type == typeof(bool))
|
||||
{
|
||||
return new DataGridCheckBoxColumn();
|
||||
|
@ -923,8 +925,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <returns>The remaining amount of adjustment.</returns>
|
||||
private static double IncreaseNonStarColumnWidth(DataGridColumn column, double targetWidth, double amount)
|
||||
{
|
||||
Debug.Assert(amount > 0, "Expected strictly positive amount.");
|
||||
Debug.Assert(column.Width.UnitType != DataGridLengthUnitType.Star, "Expected column.Width.UnitType other than DataGridLengthUnitType.Star.");
|
||||
DiagnosticsDebug.Assert(amount > 0, "Expected strictly positive amount.");
|
||||
DiagnosticsDebug.Assert(column.Width.UnitType != DataGridLengthUnitType.Star, "Expected column.Width.UnitType other than DataGridLengthUnitType.Star.");
|
||||
|
||||
if (targetWidth <= column.Width.DisplayValue)
|
||||
{
|
||||
|
@ -941,11 +943,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private static void RefreshCellElement(DataGridColumn dataGridColumn, DataGridRow dataGridRow, string propertyName)
|
||||
{
|
||||
Debug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
Debug.Assert(dataGridRow != null, "Expected non-null dataGridRow.");
|
||||
DiagnosticsDebug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
DiagnosticsDebug.Assert(dataGridRow != null, "Expected non-null dataGridRow.");
|
||||
|
||||
DataGridCell dataGridCell = dataGridRow.Cells[dataGridColumn.Index];
|
||||
Debug.Assert(dataGridCell != null, "Expected non-null dataGridCell.");
|
||||
DiagnosticsDebug.Assert(dataGridCell != null, "Expected non-null dataGridCell.");
|
||||
FrameworkElement element = dataGridCell.Content as FrameworkElement;
|
||||
if (element != null)
|
||||
{
|
||||
|
@ -1165,7 +1167,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
}
|
||||
|
||||
Debug.Assert(cx <= this.ColumnsInternal.GetVisibleFrozenEdgedColumnsWidth(), "cx smaller than or equal to ColumnsInternal.GetVisibleFrozenEdgedColumnsWidth().");
|
||||
DiagnosticsDebug.Assert(cx <= this.ColumnsInternal.GetVisibleFrozenEdgedColumnsWidth(), "cx smaller than or equal to ColumnsInternal.GetVisibleFrozenEdgedColumnsWidth().");
|
||||
|
||||
if (cx < displayWidth && firstDisplayedScrollingCol >= 0)
|
||||
{
|
||||
|
@ -1198,7 +1200,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// if we inflate the data area then we paint columns to the left of firstDisplayedScrollingCol
|
||||
if (cx < displayWidth)
|
||||
{
|
||||
Debug.Assert(firstDisplayedScrollingCol >= 0, "Expected positive firstDisplayedScrollingCol.");
|
||||
DiagnosticsDebug.Assert(firstDisplayedScrollingCol >= 0, "Expected positive firstDisplayedScrollingCol.");
|
||||
|
||||
// first minimize value of _negHorizontalOffset
|
||||
if (_negHorizontalOffset > 0)
|
||||
|
@ -1232,7 +1234,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// second try to scroll entire columns
|
||||
if (cx < displayWidth && _horizontalOffset > 0)
|
||||
{
|
||||
Debug.Assert(_negHorizontalOffset == 0, "Expected _negHorizontalOffset equals 0.");
|
||||
DiagnosticsDebug.Assert(_negHorizontalOffset == 0, "Expected _negHorizontalOffset equals 0.");
|
||||
dataGridColumn = this.ColumnsInternal.GetPreviousVisibleScrollingColumn(this.ColumnsItemsInternal[firstDisplayedScrollingCol]);
|
||||
while (dataGridColumn != null && cx + GetEdgedColumnWidth(dataGridColumn) <= displayWidth)
|
||||
{
|
||||
|
@ -1248,21 +1250,21 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// third try to partially scroll in first scrolled off column
|
||||
if (cx < displayWidth && _horizontalOffset > 0)
|
||||
{
|
||||
Debug.Assert(_negHorizontalOffset == 0, "Expected _negHorizontalOffset equals 0.");
|
||||
DiagnosticsDebug.Assert(_negHorizontalOffset == 0, "Expected _negHorizontalOffset equals 0.");
|
||||
dataGridColumn = this.ColumnsInternal.GetPreviousVisibleScrollingColumn(this.ColumnsItemsInternal[firstDisplayedScrollingCol]);
|
||||
Debug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
Debug.Assert(GetEdgedColumnWidth(dataGridColumn) > displayWidth - cx, "Expected GetEdgedColumnWidth(dataGridColumn) greater than displayWidth - cx.");
|
||||
DiagnosticsDebug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
DiagnosticsDebug.Assert(GetEdgedColumnWidth(dataGridColumn) > displayWidth - cx, "Expected GetEdgedColumnWidth(dataGridColumn) greater than displayWidth - cx.");
|
||||
firstDisplayedScrollingCol = dataGridColumn.Index;
|
||||
_negHorizontalOffset = GetEdgedColumnWidth(dataGridColumn) - displayWidth + cx;
|
||||
_horizontalOffset -= displayWidth - cx;
|
||||
visibleScrollingColumnsTmp++;
|
||||
invalidate = true;
|
||||
cx = displayWidth;
|
||||
Debug.Assert(_negHorizontalOffset == GetNegHorizontalOffsetFromHorizontalOffset(_horizontalOffset), "Expected _negHorizontalOffset equals GetNegHorizontalOffsetFromHorizontalOffset(_horizontalOffset).");
|
||||
DiagnosticsDebug.Assert(_negHorizontalOffset == GetNegHorizontalOffsetFromHorizontalOffset(_horizontalOffset), "Expected _negHorizontalOffset equals GetNegHorizontalOffsetFromHorizontalOffset(_horizontalOffset).");
|
||||
}
|
||||
|
||||
// update the number of visible columns to the new reality
|
||||
Debug.Assert(numVisibleScrollingCols <= visibleScrollingColumnsTmp, "Expected numVisibleScrollingCols less than or equal to visibleScrollingColumnsTmp.");
|
||||
DiagnosticsDebug.Assert(numVisibleScrollingCols <= visibleScrollingColumnsTmp, "Expected numVisibleScrollingCols less than or equal to visibleScrollingColumnsTmp.");
|
||||
numVisibleScrollingCols = visibleScrollingColumnsTmp;
|
||||
}
|
||||
|
||||
|
@ -1272,7 +1274,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
jumpFromFirstVisibleScrollingCol--;
|
||||
}
|
||||
|
||||
Debug.Assert(jumpFromFirstVisibleScrollingCol >= -1, "Expected jumpFromFirstVisibleScrollingCol greater than or equal to -1.");
|
||||
DiagnosticsDebug.Assert(jumpFromFirstVisibleScrollingCol >= -1, "Expected jumpFromFirstVisibleScrollingCol greater than or equal to -1.");
|
||||
|
||||
if (jumpFromFirstVisibleScrollingCol < 0)
|
||||
{
|
||||
|
@ -1280,12 +1282,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(firstDisplayedScrollingCol >= 0, "Expected positive firstDisplayedScrollingCol.");
|
||||
DiagnosticsDebug.Assert(firstDisplayedScrollingCol >= 0, "Expected positive firstDisplayedScrollingCol.");
|
||||
dataGridColumn = this.ColumnsItemsInternal[firstDisplayedScrollingCol];
|
||||
for (int jump = 0; jump < jumpFromFirstVisibleScrollingCol; jump++)
|
||||
{
|
||||
dataGridColumn = this.ColumnsInternal.GetNextVisibleColumn(dataGridColumn);
|
||||
Debug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
DiagnosticsDebug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
}
|
||||
|
||||
this.DisplayData.LastTotallyDisplayedScrollingCol = dataGridColumn.Index;
|
||||
|
@ -1332,7 +1334,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
if (dataGridColumn == null)
|
||||
{
|
||||
Debug.Assert(cx <= _horizontalOffset, "Expected cx less than or equal to _horizontalOffset.");
|
||||
DiagnosticsDebug.Assert(cx <= _horizontalOffset, "Expected cx less than or equal to _horizontalOffset.");
|
||||
dataGridColumn = this.ColumnsInternal.FirstVisibleScrollingColumn;
|
||||
if (dataGridColumn == null)
|
||||
{
|
||||
|
@ -1360,10 +1362,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
// Column indexes have already been adjusted.
|
||||
// This column has already been detached and has retained its old Index and DisplayIndex
|
||||
Debug.Assert(deletedColumn != null, "Expected non-null deletedColumn.");
|
||||
Debug.Assert(deletedColumn.OwningGrid == null, "Expected null deletedColumn.OwningGrid.");
|
||||
Debug.Assert(deletedColumn.Index >= 0, "Expected positive deletedColumn.Index.");
|
||||
Debug.Assert(deletedColumn.DisplayIndexWithFiller >= 0, "Expected positive deletedColumn.DisplayIndexWithFiller.");
|
||||
DiagnosticsDebug.Assert(deletedColumn != null, "Expected non-null deletedColumn.");
|
||||
DiagnosticsDebug.Assert(deletedColumn.OwningGrid == null, "Expected null deletedColumn.OwningGrid.");
|
||||
DiagnosticsDebug.Assert(deletedColumn.Index >= 0, "Expected positive deletedColumn.Index.");
|
||||
DiagnosticsDebug.Assert(deletedColumn.DisplayIndexWithFiller >= 0, "Expected positive deletedColumn.DisplayIndexWithFiller.");
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -1389,7 +1391,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
|
||||
#if DEBUG
|
||||
Debug.Assert(this.ColumnsInternal.Debug_VerifyColumnDisplayIndexes(), "Expected ColumnsInternal.Debug_VerifyColumnDisplayIndexes() is true.");
|
||||
DiagnosticsDebug.Assert(this.ColumnsInternal.Debug_VerifyColumnDisplayIndexes(), "Expected ColumnsInternal.Debug_VerifyColumnDisplayIndexes() is true.");
|
||||
#endif
|
||||
|
||||
// Now raise all the OnColumnDisplayIndexChanged events
|
||||
|
@ -1404,8 +1406,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void CorrectColumnDisplayIndexesAfterInsertion(DataGridColumn insertedColumn)
|
||||
{
|
||||
Debug.Assert(insertedColumn != null, "Expected non-null insertedColumn.");
|
||||
Debug.Assert(insertedColumn.OwningGrid == this, "Expected insertedColumn.OwningGrid equals this DataGrid.");
|
||||
DiagnosticsDebug.Assert(insertedColumn != null, "Expected non-null insertedColumn.");
|
||||
DiagnosticsDebug.Assert(insertedColumn.OwningGrid == this, "Expected insertedColumn.OwningGrid equals this DataGrid.");
|
||||
if (insertedColumn.DisplayIndexWithFiller == -1 || insertedColumn.DisplayIndexWithFiller >= this.ColumnsItemsInternal.Count)
|
||||
{
|
||||
// Developer did not assign a DisplayIndex or picked a large number.
|
||||
|
@ -1438,7 +1440,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
this.ColumnsInternal.DisplayIndexMap.Insert(insertedColumn.DisplayIndexWithFiller, insertedColumn.Index);
|
||||
|
||||
#if DEBUG
|
||||
Debug.Assert(this.ColumnsInternal.Debug_VerifyColumnDisplayIndexes(), "Expected ColumnsInternal.Debug_VerifyColumnDisplayIndexes() is true.");
|
||||
DiagnosticsDebug.Assert(this.ColumnsInternal.Debug_VerifyColumnDisplayIndexes(), "Expected ColumnsInternal.Debug_VerifyColumnDisplayIndexes() is true.");
|
||||
#endif
|
||||
|
||||
// Now raise all the OnColumnDisplayIndexChanged events
|
||||
|
@ -1484,18 +1486,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void CorrectColumnIndexesAfterDeletion(DataGridColumn deletedColumn)
|
||||
{
|
||||
Debug.Assert(deletedColumn != null, "Expected non-null deletedColumn.");
|
||||
DiagnosticsDebug.Assert(deletedColumn != null, "Expected non-null deletedColumn.");
|
||||
for (int columnIndex = deletedColumn.Index; columnIndex < this.ColumnsItemsInternal.Count; columnIndex++)
|
||||
{
|
||||
this.ColumnsItemsInternal[columnIndex].Index = this.ColumnsItemsInternal[columnIndex].Index - 1;
|
||||
Debug.Assert(this.ColumnsItemsInternal[columnIndex].Index == columnIndex, "Expected ColumnsItemsInternal[columnIndex].Index equals columnIndex.");
|
||||
DiagnosticsDebug.Assert(this.ColumnsItemsInternal[columnIndex].Index == columnIndex, "Expected ColumnsItemsInternal[columnIndex].Index equals columnIndex.");
|
||||
}
|
||||
}
|
||||
|
||||
private void CorrectColumnIndexesAfterInsertion(DataGridColumn insertedColumn, int insertionCount)
|
||||
{
|
||||
Debug.Assert(insertedColumn != null, "Expected non-null insertedColumn.");
|
||||
Debug.Assert(insertionCount > 0, "Expected strictly positive insertionCount.");
|
||||
DiagnosticsDebug.Assert(insertedColumn != null, "Expected non-null insertedColumn.");
|
||||
DiagnosticsDebug.Assert(insertionCount > 0, "Expected strictly positive insertionCount.");
|
||||
for (int columnIndex = insertedColumn.Index + insertionCount; columnIndex < this.ColumnsItemsInternal.Count; columnIndex++)
|
||||
{
|
||||
this.ColumnsItemsInternal[columnIndex].Index = columnIndex;
|
||||
|
@ -1549,7 +1551,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
column.DisplayIndexHasChanged = false;
|
||||
if (raiseEvent)
|
||||
{
|
||||
Debug.Assert(column != this.ColumnsInternal.RowGroupSpacerColumn, "Expected column other than ColumnsInternal.RowGroupSpacerColumn.");
|
||||
DiagnosticsDebug.Assert(column != this.ColumnsInternal.RowGroupSpacerColumn, "Expected column other than ColumnsInternal.RowGroupSpacerColumn.");
|
||||
OnColumnDisplayIndexChanged(column);
|
||||
}
|
||||
}
|
||||
|
@ -1630,7 +1632,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private bool GetColumnEffectiveReadOnlyState(DataGridColumn dataGridColumn)
|
||||
{
|
||||
Debug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
DiagnosticsDebug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
|
||||
return this.IsReadOnly || dataGridColumn.IsReadOnly || dataGridColumn is DataGridFillerColumn;
|
||||
}
|
||||
|
@ -1643,8 +1645,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <returns>Absolute coordinate of the left edge of the given column.</returns>
|
||||
private double GetColumnXFromIndex(int index)
|
||||
{
|
||||
Debug.Assert(index < this.ColumnsItemsInternal.Count, "Expected index smaller than this.ColumnsItemsInternal.Count.");
|
||||
Debug.Assert(this.ColumnsItemsInternal[index].IsVisible, "Expected ColumnsItemsInternal[index].IsVisible is true.");
|
||||
DiagnosticsDebug.Assert(index < this.ColumnsItemsInternal.Count, "Expected index smaller than this.ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(this.ColumnsItemsInternal[index].IsVisible, "Expected ColumnsItemsInternal[index].IsVisible is true.");
|
||||
|
||||
double x = 0;
|
||||
foreach (DataGridColumn column in this.ColumnsInternal.GetVisibleColumns())
|
||||
|
@ -1715,11 +1717,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void InsertDisplayedColumnHeader(DataGridColumn dataGridColumn)
|
||||
{
|
||||
Debug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
DiagnosticsDebug.Assert(dataGridColumn != null, "Expected non-null dataGridColumn.");
|
||||
if (_columnHeadersPresenter != null)
|
||||
{
|
||||
dataGridColumn.HeaderCell.Visibility = dataGridColumn.Visibility;
|
||||
Debug.Assert(!_columnHeadersPresenter.Children.Contains(dataGridColumn.HeaderCell), "Expected dataGridColumn.HeaderCell not contained in _columnHeadersPresenter.Children.");
|
||||
DiagnosticsDebug.Assert(!_columnHeadersPresenter.Children.Contains(dataGridColumn.HeaderCell), "Expected dataGridColumn.HeaderCell not contained in _columnHeadersPresenter.Children.");
|
||||
_columnHeadersPresenter.Children.Insert(dataGridColumn.DisplayIndexWithFiller, dataGridColumn.HeaderCell);
|
||||
}
|
||||
}
|
||||
|
@ -1755,8 +1757,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private bool ScrollColumnIntoView(int columnIndex)
|
||||
{
|
||||
Debug.Assert(columnIndex >= 0, "Expected positive columnIndex.");
|
||||
Debug.Assert(columnIndex < this.ColumnsItemsInternal.Count, "Expected columnIndex smaller than this.ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(columnIndex >= 0, "Expected positive columnIndex.");
|
||||
DiagnosticsDebug.Assert(columnIndex < this.ColumnsItemsInternal.Count, "Expected columnIndex smaller than this.ColumnsItemsInternal.Count.");
|
||||
|
||||
if (this.DisplayData.FirstDisplayedScrollingCol != -1 &&
|
||||
!this.ColumnsItemsInternal[columnIndex].IsFrozen &&
|
||||
|
@ -1849,7 +1851,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
}
|
||||
|
||||
Debug.Assert(this.DisplayData.FirstDisplayedScrollingCol >= 0, "Expected positive DisplayData.FirstDisplayedScrollingCol.");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.FirstDisplayedScrollingCol >= 0, "Expected positive DisplayData.FirstDisplayedScrollingCol.");
|
||||
dataGridColumnTmp = this.ColumnsItemsInternal[this.DisplayData.FirstDisplayedScrollingCol];
|
||||
colCount = 0;
|
||||
while (colCount < columns && dataGridColumnTmp != null)
|
||||
|
@ -1863,7 +1865,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
if (columns < 0)
|
||||
{
|
||||
Debug.Assert(this.DisplayData.FirstDisplayedScrollingCol >= 0, "Expected positive DisplayData.FirstDisplayedScrollingCol.");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.FirstDisplayedScrollingCol >= 0, "Expected positive DisplayData.FirstDisplayedScrollingCol.");
|
||||
dataGridColumnTmp = this.ColumnsItemsInternal[this.DisplayData.FirstDisplayedScrollingCol];
|
||||
if (_negHorizontalOffset > 0)
|
||||
{
|
||||
|
|
|
@ -18,6 +18,8 @@ using Windows.Foundation;
|
|||
using Windows.Foundation.Collections;
|
||||
using Windows.UI.Xaml.Data;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
||||
{
|
||||
internal class DataGridDataConnection
|
||||
|
@ -332,7 +334,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
|||
|
||||
public static bool CanEdit(Type type)
|
||||
{
|
||||
Debug.Assert(type != null, "Expected non-null type.");
|
||||
DiagnosticsDebug.Assert(type != null, "Expected non-null type.");
|
||||
|
||||
type = type.GetNonNullableType();
|
||||
|
||||
|
@ -488,7 +490,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
|||
// Assumes index >= 0, returns null if index >= Count
|
||||
public object GetDataItem(int index)
|
||||
{
|
||||
Debug.Assert(index >= 0, "Expected positive index.");
|
||||
DiagnosticsDebug.Assert(index >= 0, "Expected positive index.");
|
||||
|
||||
IList list = this.List;
|
||||
if (list != null)
|
||||
|
@ -606,7 +608,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
|||
|
||||
public void LoadMoreItems(uint count)
|
||||
{
|
||||
Debug.Assert(_loadingOperation == null, "Expected _loadingOperation == null.");
|
||||
DiagnosticsDebug.Assert(_loadingOperation == null, "Expected _loadingOperation == null.");
|
||||
|
||||
_loadingOperation = _incrementalItemsSource.LoadMoreItemsAsync(count);
|
||||
|
||||
|
@ -633,8 +635,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
|||
#endif
|
||||
internal static ICollectionView CreateView(IEnumerable source)
|
||||
{
|
||||
Debug.Assert(source != null, "source unexpectedly null");
|
||||
Debug.Assert(!(source is ICollectionView), "source is an ICollectionView");
|
||||
DiagnosticsDebug.Assert(source != null, "source unexpectedly null");
|
||||
DiagnosticsDebug.Assert(!(source is ICollectionView), "source is an ICollectionView");
|
||||
|
||||
ICollectionView collectionView = null;
|
||||
|
||||
|
@ -894,8 +896,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
|||
switch (e.Action)
|
||||
{
|
||||
case NotifyCollectionChangedAction.Add:
|
||||
Debug.Assert(e.NewItems != null, "Unexpected NotifyCollectionChangedAction.Add notification");
|
||||
Debug.Assert(this.ShouldAutoGenerateColumns || this.IsGrouping || e.NewItems.Count == 1, "Expected NewItems.Count equals 1.");
|
||||
DiagnosticsDebug.Assert(e.NewItems != null, "Unexpected NotifyCollectionChangedAction.Add notification");
|
||||
DiagnosticsDebug.Assert(this.ShouldAutoGenerateColumns || this.IsGrouping || e.NewItems.Count == 1, "Expected NewItems.Count equals 1.");
|
||||
NotifyingDataSource_Add(e.NewStartingIndex);
|
||||
break;
|
||||
|
||||
|
@ -903,7 +905,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
|||
IList removedItems = e.OldItems;
|
||||
if (removedItems == null || e.OldStartingIndex < 0)
|
||||
{
|
||||
Debug.Assert(false, "Unexpected NotifyCollectionChangedAction.Remove notification");
|
||||
DiagnosticsDebug.Assert(false, "Unexpected NotifyCollectionChangedAction.Remove notification");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -913,7 +915,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
|||
// Remove is a single item operation.
|
||||
foreach (object item in removedItems)
|
||||
{
|
||||
Debug.Assert(item != null, "Expected non-null item.");
|
||||
DiagnosticsDebug.Assert(item != null, "Expected non-null item.");
|
||||
_owner.RemoveRowAt(e.OldStartingIndex, item);
|
||||
}
|
||||
}
|
||||
|
@ -1019,7 +1021,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
|||
if (this.DataSource != null && dataType != null && !DataTypeIsPrimitive(dataType))
|
||||
{
|
||||
_dataProperties = dataType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
||||
Debug.Assert(_dataProperties != null, "Expected non-null _dataProperties.");
|
||||
DiagnosticsDebug.Assert(_dataProperties != null, "Expected non-null _dataProperties.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -7,6 +7,8 @@ using System.Diagnostics;
|
|||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
||||
{
|
||||
internal class DataGridDisplayData
|
||||
|
@ -80,7 +82,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
|||
|
||||
internal void AddRecylableRow(DataGridRow row)
|
||||
{
|
||||
Debug.Assert(!_recyclableRows.Contains(row), "Expected row parameter to be non-recyclable.");
|
||||
DiagnosticsDebug.Assert(!_recyclableRows.Contains(row), "Expected row parameter to be non-recyclable.");
|
||||
|
||||
row.DetachFromDataGrid(true);
|
||||
_recyclableRows.Push(row);
|
||||
|
@ -88,7 +90,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
|||
|
||||
internal void AddRecylableRowGroupHeader(DataGridRowGroupHeader groupHeader)
|
||||
{
|
||||
Debug.Assert(!_recyclableGroupHeaders.Contains(groupHeader), "Expected groupHeader parameter to be non-recyclable.");
|
||||
DiagnosticsDebug.Assert(!_recyclableGroupHeaders.Contains(groupHeader), "Expected groupHeader parameter to be non-recyclable.");
|
||||
|
||||
groupHeader.PropertyName = null;
|
||||
groupHeader.PropertyValue = null;
|
||||
|
@ -173,7 +175,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
|||
}
|
||||
else if ((_owner.GetPreviousVisibleSlot(slot) <= this.LastScrollingSlot) || (this.LastScrollingSlot == -1))
|
||||
{
|
||||
Debug.Assert(element != null, "Expected non-null element.");
|
||||
DiagnosticsDebug.Assert(element != null, "Expected non-null element.");
|
||||
|
||||
// The row was inserted in our viewport, add it as a scrolling row
|
||||
LoadScrollingSlot(slot, element, true /*updateSlotInformation*/);
|
||||
|
@ -192,9 +194,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
|||
while (_recyclableRows.Count > 0)
|
||||
{
|
||||
DataGridRow row = _recyclableRows.Pop();
|
||||
Debug.Assert(row != null, "Expected non-null row.");
|
||||
DiagnosticsDebug.Assert(row != null, "Expected non-null row.");
|
||||
row.Visibility = Visibility.Collapsed;
|
||||
Debug.Assert(!_fullyRecycledRows.Contains(row), "Expected row not in _fullyRecycledRows.");
|
||||
DiagnosticsDebug.Assert(!_fullyRecycledRows.Contains(row), "Expected row not in _fullyRecycledRows.");
|
||||
_fullyRecycledRows.Push(row);
|
||||
}
|
||||
|
||||
|
@ -202,17 +204,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
|||
while (_recyclableGroupHeaders.Count > 0)
|
||||
{
|
||||
DataGridRowGroupHeader groupHeader = _recyclableGroupHeaders.Pop();
|
||||
Debug.Assert(groupHeader != null, "Expected non-null groupHeader.");
|
||||
DiagnosticsDebug.Assert(groupHeader != null, "Expected non-null groupHeader.");
|
||||
groupHeader.Visibility = Visibility.Collapsed;
|
||||
Debug.Assert(!_fullyRecycledGroupHeaders.Contains(groupHeader), "Expected groupHeader not in _fullyRecycledGroupHeaders.");
|
||||
DiagnosticsDebug.Assert(!_fullyRecycledGroupHeaders.Contains(groupHeader), "Expected groupHeader not in _fullyRecycledGroupHeaders.");
|
||||
_fullyRecycledGroupHeaders.Push(groupHeader);
|
||||
}
|
||||
}
|
||||
|
||||
internal UIElement GetDisplayedElement(int slot)
|
||||
{
|
||||
Debug.Assert(slot >= this.FirstScrollingSlot, "Expected slot greater than or equal to FirstScrollingSlot.");
|
||||
Debug.Assert(slot <= this.LastScrollingSlot, "Expected slot less than or equal to LastScrollingSlot.");
|
||||
DiagnosticsDebug.Assert(slot >= this.FirstScrollingSlot, "Expected slot greater than or equal to FirstScrollingSlot.");
|
||||
DiagnosticsDebug.Assert(slot <= this.LastScrollingSlot, "Expected slot less than or equal to LastScrollingSlot.");
|
||||
|
||||
return _scrollingElements[GetCircularListIndex(slot, true /*wrap*/)];
|
||||
}
|
||||
|
@ -282,8 +284,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
|||
else
|
||||
{
|
||||
// The slot should be adjacent to the other slots being displayed
|
||||
Debug.Assert(slot >= _owner.GetPreviousVisibleSlot(this.FirstScrollingSlot), "Expected slot greater than or equal to _owner.GetPreviousVisibleSlot(this.FirstScrollingSlot).");
|
||||
Debug.Assert(slot <= _owner.GetNextVisibleSlot(this.LastScrollingSlot), "Expected slot smaller than or equal to _owner.GetNextVisibleSlot(this.LastScrollingSlot).");
|
||||
DiagnosticsDebug.Assert(slot >= _owner.GetPreviousVisibleSlot(this.FirstScrollingSlot), "Expected slot greater than or equal to _owner.GetPreviousVisibleSlot(this.FirstScrollingSlot).");
|
||||
DiagnosticsDebug.Assert(slot <= _owner.GetNextVisibleSlot(this.LastScrollingSlot), "Expected slot smaller than or equal to _owner.GetNextVisibleSlot(this.LastScrollingSlot).");
|
||||
if (updateSlotInformation)
|
||||
{
|
||||
if (slot < this.FirstScrollingSlot)
|
||||
|
@ -324,7 +326,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals
|
|||
// Stops tracking the element at the given slot as a scrolling element
|
||||
internal void UnloadScrollingElement(int slot, bool updateSlotInformation, bool wasDeleted)
|
||||
{
|
||||
Debug.Assert(_owner.IsSlotVisible(slot), "Expected slot is visible.");
|
||||
DiagnosticsDebug.Assert(_owner.IsSlotVisible(slot), "Expected slot is visible.");
|
||||
|
||||
int elementIndex = GetCircularListIndex(slot, false /*wrap*/);
|
||||
if (elementIndex > _scrollingElements.Count)
|
||||
|
|
|
@ -6,6 +6,8 @@ using System.Diagnostics;
|
|||
using Microsoft.Toolkit.Uwp.UI.Controls.Primitives;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
internal class DataGridFillerColumn : DataGridColumn
|
||||
|
@ -66,7 +68,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
protected override object PrepareCellForEdit(FrameworkElement editingElement, RoutedEventArgs editingEventArgs)
|
||||
{
|
||||
Debug.Assert(false, "Unexpected call to DataGridFillerColumn.PrepareCellForEdit.");
|
||||
DiagnosticsDebug.Assert(false, "Unexpected call to DataGridFillerColumn.PrepareCellForEdit.");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ using Windows.UI.Xaml.Input;
|
|||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -216,9 +218,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
private static void OnDetailsTemplatePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
DataGridRow source = d as DataGridRow;
|
||||
Debug.Assert(source != null, "The source is not an instance of DataGridRow!");
|
||||
DiagnosticsDebug.Assert(source != null, "The source is not an instance of DataGridRow!");
|
||||
|
||||
Debug.Assert(
|
||||
DiagnosticsDebug.Assert(
|
||||
(e.NewValue == null) ||
|
||||
typeof(DataTemplate).IsInstanceOfType(e.NewValue),
|
||||
"The e.NewValue is not an instance of DataTemplate.");
|
||||
|
@ -453,7 +455,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
get
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
|
||||
if (_fillerCell == null)
|
||||
{
|
||||
|
@ -579,7 +581,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return false;
|
||||
}
|
||||
|
||||
Debug.Assert(this.Index != -1, "Expected Index other than -1.");
|
||||
DiagnosticsDebug.Assert(this.Index != -1, "Expected Index other than -1.");
|
||||
return this.OwningGrid.GetRowSelection(this.Slot);
|
||||
}
|
||||
}
|
||||
|
@ -616,8 +618,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
this.EnsureMeasured();
|
||||
if (_detailsElement != null && _appliedDetailsVisibility == Visibility.Visible && _appliedDetailsTemplate != null)
|
||||
{
|
||||
Debug.Assert(!double.IsNaN(_detailsElement.ContentHeight), "Expected _detailsElement.ContentHeight different from double.NaN.");
|
||||
Debug.Assert(!double.IsNaN(_detailsDesiredHeight), "Expected _detailsDesiredHeight different from double.NaN.");
|
||||
DiagnosticsDebug.Assert(!double.IsNaN(_detailsElement.ContentHeight), "Expected _detailsElement.ContentHeight different from double.NaN.");
|
||||
DiagnosticsDebug.Assert(!double.IsNaN(_detailsDesiredHeight), "Expected _detailsDesiredHeight different from double.NaN.");
|
||||
return this.DesiredSize.Height + _detailsDesiredHeight - _detailsElement.ContentHeight;
|
||||
}
|
||||
else
|
||||
|
@ -634,7 +636,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
get
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
DataTemplate currentDetailsTemplate = this.DetailsTemplate;
|
||||
|
||||
return currentDetailsTemplate != null ? currentDetailsTemplate : this.OwningGrid.RowDetailsTemplate;
|
||||
|
@ -976,7 +978,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
if (this.RootElement != null && this.OwningGrid != null && this.Visibility == Visibility.Visible)
|
||||
{
|
||||
Debug.Assert(this.Index != -1, "Expected Index other than -1.");
|
||||
DiagnosticsDebug.Assert(this.Index != -1, "Expected Index other than -1.");
|
||||
byte idealStateMappingIndex = 0;
|
||||
if (this.IsSelected || this.IsEditing)
|
||||
{
|
||||
|
@ -999,7 +1001,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
|
||||
byte stateCode = _idealStateMapping[idealStateMappingIndex];
|
||||
Debug.Assert(stateCode != DATAGRIDROW_stateNullCode, "stateCode other than DATAGRIDROW_stateNullCode.");
|
||||
DiagnosticsDebug.Assert(stateCode != DATAGRIDROW_stateNullCode, "stateCode other than DATAGRIDROW_stateNullCode.");
|
||||
|
||||
string storyboardName;
|
||||
while (stateCode != DATAGRIDROW_stateNullCode)
|
||||
|
@ -1077,7 +1079,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// Inherit the DataGrid's RowBackground properties only if this row doesn't explicitly have a background set
|
||||
if (this.RootElement != null && this.OwningGrid != null)
|
||||
{
|
||||
Debug.Assert(this.Index != -1, "Expected Index other than -1.");
|
||||
DiagnosticsDebug.Assert(this.Index != -1, "Expected Index other than -1.");
|
||||
|
||||
Brush newBackground = null;
|
||||
if (this.Background == null)
|
||||
|
@ -1118,7 +1120,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// Inherit the DataGrid's RowForeground properties only if this row doesn't explicitly have a foreground set
|
||||
if (this.OwningGrid != null)
|
||||
{
|
||||
Debug.Assert(this.Index != -1, "Expected Index other than -1.");
|
||||
DiagnosticsDebug.Assert(this.Index != -1, "Expected Index other than -1.");
|
||||
|
||||
PropertyMetadata metadataInfo = DataGridRow.ForegroundProperty.GetMetadata(typeof(DataGridRow));
|
||||
Brush defaultForeground = metadataInfo == null ? null : metadataInfo.DefaultValue as Brush;
|
||||
|
@ -1246,8 +1248,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
Visibility visibility,
|
||||
bool raiseNotification)
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
Debug.Assert(this.Index != -1, "Expected Index other than -1.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
DiagnosticsDebug.Assert(this.Index != -1, "Expected Index other than -1.");
|
||||
|
||||
if (_appliedDetailsVisibility != visibility)
|
||||
{
|
||||
|
@ -1411,12 +1413,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// height we want to animate to. Subsequently, we just update that height in response to SizeChanged.
|
||||
private void EnsureDetailsDesiredHeight()
|
||||
{
|
||||
Debug.Assert(_detailsElement != null, "Expected non-null _detailsElement.");
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
DiagnosticsDebug.Assert(_detailsElement != null, "Expected non-null _detailsElement.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
|
||||
if (_detailsContent != null)
|
||||
{
|
||||
Debug.Assert(_detailsElement.Children.Contains(_detailsContent), "Expected _detailsElement parent of _detailsContent.");
|
||||
DiagnosticsDebug.Assert(_detailsElement.Children.Contains(_detailsContent), "Expected _detailsElement parent of _detailsContent.");
|
||||
|
||||
_detailsContent.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
_detailsDesiredHeight = _detailsContent.DesiredSize.Height;
|
||||
|
|
|
@ -21,6 +21,8 @@ using Windows.UI.Xaml.Input;
|
|||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Shapes;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -281,7 +283,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
get
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null OwningGrid.");
|
||||
return this.RowGroupInfo.Slot == this.OwningGrid.CurrentSlot;
|
||||
}
|
||||
}
|
||||
|
@ -459,7 +461,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
if (!e.Handled && this.OwningGrid.IsTabStop)
|
||||
{
|
||||
bool success = this.OwningGrid.Focus(FocusState.Programmatic);
|
||||
Debug.Assert(success, "Expected successful focus change.");
|
||||
DiagnosticsDebug.Assert(success, "Expected successful focus change.");
|
||||
}
|
||||
|
||||
e.Handled = this.OwningGrid.UpdateStateOnTapped(e, this.OwningGrid.CurrentColumnIndex, this.RowGroupInfo.Slot, false /*allowEdit*/);
|
||||
|
|
|
@ -13,6 +13,8 @@ using Windows.UI.Xaml.Controls;
|
|||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -368,7 +370,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
}
|
||||
|
||||
byte stateCode = _idealStateMapping[idealStateMappingIndex];
|
||||
Debug.Assert(stateCode != DATAGRIDROWHEADER_stateNullCode, "Expected stateCode other than DATAGRIDROWHEADER_stateNullCode.");
|
||||
DiagnosticsDebug.Assert(stateCode != DATAGRIDROWHEADER_stateNullCode, "Expected stateCode other than DATAGRIDROWHEADER_stateNullCode.");
|
||||
|
||||
string storyboardName;
|
||||
while (stateCode != DATAGRIDROWHEADER_stateNullCode)
|
||||
|
@ -426,13 +428,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
if (!e.Handled && this.OwningGrid.IsTabStop)
|
||||
{
|
||||
bool success = this.OwningGrid.Focus(FocusState.Programmatic);
|
||||
Debug.Assert(success, "Expected successful focus change.");
|
||||
DiagnosticsDebug.Assert(success, "Expected successful focus change.");
|
||||
}
|
||||
|
||||
if (this.OwningRow != null)
|
||||
{
|
||||
Debug.Assert(sender is DataGridRowHeader, "Expected sender is DataGridRowHeader.");
|
||||
Debug.Assert(sender == this, "Expected sender is this.");
|
||||
DiagnosticsDebug.Assert(sender is DataGridRowHeader, "Expected sender is DataGridRowHeader.");
|
||||
DiagnosticsDebug.Assert(sender == this, "Expected sender is this.");
|
||||
|
||||
e.Handled = this.OwningGrid.UpdateStateOnTapped(e, -1, this.Slot, false /*allowEdit*/);
|
||||
this.OwningGrid.UpdatedStateOnTapped = true;
|
||||
|
|
|
@ -16,6 +16,8 @@ using Windows.UI.Xaml;
|
|||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -83,9 +85,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return 0;
|
||||
}
|
||||
|
||||
Debug.Assert(this.DisplayData.LastScrollingSlot >= 0, "Expected positive DisplayData.LastScrollingSlot.");
|
||||
Debug.Assert(_verticalOffset >= 0, "Expected positive _verticalOffset.");
|
||||
Debug.Assert(this.NegVerticalOffset >= 0, "Expected positive NegVerticalOffset.");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.LastScrollingSlot >= 0, "Expected positive DisplayData.LastScrollingSlot.");
|
||||
DiagnosticsDebug.Assert(_verticalOffset >= 0, "Expected positive _verticalOffset.");
|
||||
DiagnosticsDebug.Assert(this.NegVerticalOffset >= 0, "Expected positive NegVerticalOffset.");
|
||||
|
||||
// Height of all rows above the viewport
|
||||
double totalRowsHeight = _verticalOffset - this.NegVerticalOffset;
|
||||
|
@ -344,7 +346,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal Visibility GetRowDetailsVisibility(int rowIndex, DataGridRowDetailsVisibilityMode gridLevelRowDetailsVisibility)
|
||||
{
|
||||
Debug.Assert(rowIndex != -1, "Expected rowIndex other than -1.");
|
||||
DiagnosticsDebug.Assert(rowIndex != -1, "Expected rowIndex other than -1.");
|
||||
if (_showDetailsTable.Contains(rowIndex))
|
||||
{
|
||||
// The user explicitly set DetailsVisibility on a row so we should respect that
|
||||
|
@ -384,7 +386,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal bool GetRowSelection(int slot)
|
||||
{
|
||||
Debug.Assert(slot != -1, "Expected slot other than -1.");
|
||||
DiagnosticsDebug.Assert(slot != -1, "Expected slot other than -1.");
|
||||
return _selectedItems.ContainsSlot(slot);
|
||||
}
|
||||
|
||||
|
@ -395,8 +397,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
DataGridRowGroupInfo groupInfo,
|
||||
bool isCollapsed)
|
||||
{
|
||||
Debug.Assert(slot >= 0, "Expected positive slot.");
|
||||
Debug.Assert(slot <= this.SlotCount, "Expected slot smaller than or equal to SlotCount.");
|
||||
DiagnosticsDebug.Assert(slot >= 0, "Expected positive slot.");
|
||||
DiagnosticsDebug.Assert(slot <= this.SlotCount, "Expected slot smaller than or equal to SlotCount.");
|
||||
|
||||
bool isRow = rowIndex != -1;
|
||||
if (isCollapsed || (this.IsReadOnly && rowIndex == this.DataConnection.NewItemPlaceholderIndex))
|
||||
|
@ -467,15 +469,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal void OnRowDetailsVisibilityPropertyChanged(int rowIndex, Visibility visibility)
|
||||
{
|
||||
Debug.Assert(rowIndex >= 0, "Expected positive rowIndex.");
|
||||
Debug.Assert(rowIndex < this.SlotCount, "Expected rowIndex smaller than SlotCount.");
|
||||
DiagnosticsDebug.Assert(rowIndex >= 0, "Expected positive rowIndex.");
|
||||
DiagnosticsDebug.Assert(rowIndex < this.SlotCount, "Expected rowIndex smaller than SlotCount.");
|
||||
|
||||
_showDetailsTable.AddValue(rowIndex, visibility);
|
||||
}
|
||||
|
||||
internal void OnRowGroupHeaderToggled(DataGridRowGroupHeader groupHeader, Visibility newVisibility, bool setCurrent)
|
||||
{
|
||||
Debug.Assert(groupHeader.RowGroupInfo.CollectionViewGroup.GroupItems.Count > 0, "Expected positive groupHeader.RowGroupInfo.CollectionViewGroup.GroupItems.Count.");
|
||||
DiagnosticsDebug.Assert(groupHeader.RowGroupInfo.CollectionViewGroup.GroupItems.Count > 0, "Expected positive groupHeader.RowGroupInfo.CollectionViewGroup.GroupItems.Count.");
|
||||
|
||||
if (this.WaitForLostFocus(() => { this.OnRowGroupHeaderToggled(groupHeader, newVisibility, setCurrent); }) || !this.CommitEdit())
|
||||
{
|
||||
|
@ -507,17 +509,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal void OnSublevelIndentUpdated(DataGridRowGroupHeader groupHeader, double newValue)
|
||||
{
|
||||
Debug.Assert(this.DataConnection.CollectionView != null, "Expected non-null DataConnection.CollectionView.");
|
||||
Debug.Assert(this.DataConnection.CollectionView.CollectionGroups != null, "Expected non-null DataConnection.CollectionView.CollectionGroups.");
|
||||
Debug.Assert(this.RowGroupSublevelIndents != null, "Expected non-null RowGroupSublevelIndents.");
|
||||
DiagnosticsDebug.Assert(this.DataConnection.CollectionView != null, "Expected non-null DataConnection.CollectionView.");
|
||||
DiagnosticsDebug.Assert(this.DataConnection.CollectionView.CollectionGroups != null, "Expected non-null DataConnection.CollectionView.CollectionGroups.");
|
||||
DiagnosticsDebug.Assert(this.RowGroupSublevelIndents != null, "Expected non-null RowGroupSublevelIndents.");
|
||||
|
||||
#if FEATURE_ICOLLECTIONVIEW_GROUP
|
||||
int groupLevelCount = this.DataConnection.CollectionView.GroupDescriptions.Count;
|
||||
#else
|
||||
int groupLevelCount = 1;
|
||||
#endif
|
||||
Debug.Assert(groupHeader.Level >= 0, "Expected positive groupHeader.Level.");
|
||||
Debug.Assert(groupHeader.Level < groupLevelCount, "Expected groupHeader.Level smaller than groupLevelCount.");
|
||||
DiagnosticsDebug.Assert(groupHeader.Level >= 0, "Expected positive groupHeader.Level.");
|
||||
DiagnosticsDebug.Assert(groupHeader.Level < groupLevelCount, "Expected groupHeader.Level smaller than groupLevelCount.");
|
||||
|
||||
double oldValue = this.RowGroupSublevelIndents[groupHeader.Level];
|
||||
if (groupHeader.Level > 0)
|
||||
|
@ -530,7 +532,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
for (int i = groupHeader.Level; i < groupLevelCount; i++)
|
||||
{
|
||||
this.RowGroupSublevelIndents[i] += change;
|
||||
Debug.Assert(this.RowGroupSublevelIndents[i] >= 0, "Expected positive RowGroupSublevelIndents[i].");
|
||||
DiagnosticsDebug.Assert(this.RowGroupSublevelIndents[i] >= 0, "Expected positive RowGroupSublevelIndents[i].");
|
||||
}
|
||||
|
||||
EnsureRowGroupSpacerColumnWidth(groupLevelCount);
|
||||
|
@ -629,7 +631,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal bool ScrollSlotIntoView(int slot, bool scrolledHorizontally)
|
||||
{
|
||||
Debug.Assert(_collapsedSlotsTable.Contains(slot) || !IsSlotOutOfBounds(slot), "Expected _collapsedSlotsTable.Contains(slot) is true or IsSlotOutOfBounds(slot) is false.");
|
||||
DiagnosticsDebug.Assert(_collapsedSlotsTable.Contains(slot) || !IsSlotOutOfBounds(slot), "Expected _collapsedSlotsTable.Contains(slot) is true or IsSlotOutOfBounds(slot) is false.");
|
||||
|
||||
if (scrolledHorizontally && this.DisplayData.FirstScrollingSlot <= slot && this.DisplayData.LastScrollingSlot >= slot)
|
||||
{
|
||||
|
@ -745,7 +747,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
|
||||
// TODO: in certain cases (eg, variable row height), this may not be true
|
||||
Debug.Assert(DoubleUtil.LessThanOrClose(this.NegVerticalOffset, _verticalOffset), "Expected NegVerticalOffset is less than or close to _verticalOffset.");
|
||||
DiagnosticsDebug.Assert(DoubleUtil.LessThanOrClose(this.NegVerticalOffset, _verticalOffset), "Expected NegVerticalOffset is less than or close to _verticalOffset.");
|
||||
|
||||
SetVerticalOffset(_verticalOffset);
|
||||
|
||||
|
@ -757,14 +759,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
internal void SetRowSelection(int slot, bool isSelected, bool setAnchorSlot)
|
||||
{
|
||||
Debug.Assert(isSelected || !setAnchorSlot, "Expected isSelected is true or setAnchorSlot is false.");
|
||||
Debug.Assert(!IsSlotOutOfSelectionBounds(slot), "Expected IsSlotOutOfSelectionBounds(slot) is false.");
|
||||
DiagnosticsDebug.Assert(isSelected || !setAnchorSlot, "Expected isSelected is true or setAnchorSlot is false.");
|
||||
DiagnosticsDebug.Assert(!IsSlotOutOfSelectionBounds(slot), "Expected IsSlotOutOfSelectionBounds(slot) is false.");
|
||||
_noSelectionChangeCount++;
|
||||
try
|
||||
{
|
||||
if (this.SelectionMode == DataGridSelectionMode.Single && isSelected)
|
||||
{
|
||||
Debug.Assert(_selectedItems.Count <= 1, "Expected _selectedItems.Count smaller than or equal to 1.");
|
||||
DiagnosticsDebug.Assert(_selectedItems.Count <= 1, "Expected _selectedItems.Count smaller than or equal to 1.");
|
||||
if (_selectedItems.Count > 0)
|
||||
{
|
||||
int currentlySelectedSlot = _selectedItems.GetIndexes().First();
|
||||
|
@ -796,11 +798,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// For now, all scenarios are for isSelected == true.
|
||||
internal void SetRowsSelection(int startSlot, int endSlot, bool isSelected = true)
|
||||
{
|
||||
Debug.Assert(startSlot >= 0, "Expected startSlot is positive.");
|
||||
Debug.Assert(startSlot < this.SlotCount, "Expected startSlot is smaller than SlotCount.");
|
||||
Debug.Assert(endSlot >= 0, "Expected endSlot is positive.");
|
||||
Debug.Assert(endSlot < this.SlotCount, "Expected endSlot is smaller than SlotCount.");
|
||||
Debug.Assert(startSlot <= endSlot, "Expected startSlot is smaller than or equal to endSlot.");
|
||||
DiagnosticsDebug.Assert(startSlot >= 0, "Expected startSlot is positive.");
|
||||
DiagnosticsDebug.Assert(startSlot < this.SlotCount, "Expected startSlot is smaller than SlotCount.");
|
||||
DiagnosticsDebug.Assert(endSlot >= 0, "Expected endSlot is positive.");
|
||||
DiagnosticsDebug.Assert(endSlot < this.SlotCount, "Expected endSlot is smaller than SlotCount.");
|
||||
DiagnosticsDebug.Assert(startSlot <= endSlot, "Expected startSlot is smaller than or equal to endSlot.");
|
||||
|
||||
_noSelectionChangeCount++;
|
||||
try
|
||||
|
@ -847,19 +849,19 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
DataGridRow row = element as DataGridRow;
|
||||
if (row != null)
|
||||
{
|
||||
Debug.Assert(row.OwningGrid == this, "Expected row.OwningGrid equals this DataGrid.");
|
||||
Debug.Assert(row.Cells.Count == this.ColumnsItemsInternal.Count, "Expected row.Cells.Count equals this.ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(row.OwningGrid == this, "Expected row.OwningGrid equals this DataGrid.");
|
||||
DiagnosticsDebug.Assert(row.Cells.Count == this.ColumnsItemsInternal.Count, "Expected row.Cells.Count equals this.ColumnsItemsInternal.Count.");
|
||||
|
||||
int columnIndex = 0;
|
||||
foreach (DataGridCell dataGridCell in row.Cells)
|
||||
{
|
||||
Debug.Assert(dataGridCell.OwningRow == row, "Expected dataGridCell.OwningRow equals row.");
|
||||
Debug.Assert(dataGridCell.OwningColumn == this.ColumnsItemsInternal[columnIndex], "Expected dataGridCell.OwningColumn equals this.ColumnsItemsInternal[columnIndex].");
|
||||
DiagnosticsDebug.Assert(dataGridCell.OwningRow == row, "Expected dataGridCell.OwningRow equals row.");
|
||||
DiagnosticsDebug.Assert(dataGridCell.OwningColumn == this.ColumnsItemsInternal[columnIndex], "Expected dataGridCell.OwningColumn equals this.ColumnsItemsInternal[columnIndex].");
|
||||
columnIndex++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Debug.Assert(slot == this.SlotCount, "Expected slot equals this.SlotCount.");
|
||||
DiagnosticsDebug.Assert(slot == this.SlotCount, "Expected slot equals this.SlotCount.");
|
||||
|
||||
OnAddedElement_Phase1(slot, element);
|
||||
this.SlotCount++;
|
||||
|
@ -918,7 +920,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
if (firstSlot >= 0)
|
||||
{
|
||||
Debug.Assert(lastSlot >= firstSlot, "lastSlot greater than or equal to firstSlot.");
|
||||
DiagnosticsDebug.Assert(lastSlot >= firstSlot, "lastSlot greater than or equal to firstSlot.");
|
||||
int slot = GetNextVisibleSlot(firstSlot - 1);
|
||||
while (slot <= lastSlot)
|
||||
{
|
||||
|
@ -1107,7 +1109,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// </summary>
|
||||
private void CorrectSlotsAfterDeletion(int slotDeleted, bool wasRow)
|
||||
{
|
||||
Debug.Assert(slotDeleted >= 0, "Expected positive slotDeleted.");
|
||||
DiagnosticsDebug.Assert(slotDeleted >= 0, "Expected positive slotDeleted.");
|
||||
|
||||
// Take care of the non-visible loaded rows
|
||||
for (int index = 0; index < _loadedRows.Count;)
|
||||
|
@ -1187,7 +1189,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// </summary>
|
||||
private void CorrectSlotsAfterInsertion(int slotInserted, bool isCollapsed, bool rowInserted)
|
||||
{
|
||||
Debug.Assert(slotInserted >= 0, "Expected positive slotInserted.");
|
||||
DiagnosticsDebug.Assert(slotInserted >= 0, "Expected positive slotInserted.");
|
||||
|
||||
// Take care of the non-visible loaded rows
|
||||
foreach (DataGridRow dataGridRow in _loadedRows)
|
||||
|
@ -1314,7 +1316,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void CollectionViewGroup_CollectionChanged_Remove(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
Debug.Assert(e.OldItems.Count == 1, "Expected e.OldItems.Count equals 1.");
|
||||
DiagnosticsDebug.Assert(e.OldItems.Count == 1, "Expected e.OldItems.Count equals 1.");
|
||||
if (e.OldItems != null && e.OldItems.Count > 0)
|
||||
{
|
||||
OnCollectionViewGroupItemRemoved(sender, e.OldItems[0], e.OldStartingIndex);
|
||||
|
@ -1437,7 +1439,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return _selectedItems.GetIndexCount(lowerBound, upperBound);
|
||||
}
|
||||
|
||||
Debug.Assert(false, "Expected known RowDetailsVisibilityMode value."); // Shouldn't ever happen
|
||||
DiagnosticsDebug.Assert(false, "Expected known RowDetailsVisibilityMode value."); // Shouldn't ever happen
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1479,7 +1481,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
if (this.IsSlotVisible(rowGroupInfo.Slot))
|
||||
{
|
||||
DataGridRowGroupHeader rowGroupHeader = this.DisplayData.GetDisplayedElement(rowGroupInfo.Slot) as DataGridRowGroupHeader;
|
||||
Debug.Assert(rowGroupHeader != null, "Expected non-null rowGroupHeader.");
|
||||
DiagnosticsDebug.Assert(rowGroupHeader != null, "Expected non-null rowGroupHeader.");
|
||||
rowGroupHeader.ToggleExpandCollapse(visibility, setCurrent);
|
||||
}
|
||||
else
|
||||
|
@ -1613,7 +1615,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
if (this.EditingRow != null && this.EditingRow.Cells != null)
|
||||
{
|
||||
Debug.Assert(this.EditingRow.Cells.Count == this.ColumnsItemsInternal.Count, "Expected EditingRow.Cells.Count equals this.ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow.Cells.Count == this.ColumnsItemsInternal.Count, "Expected EditingRow.Cells.Count equals this.ColumnsItemsInternal.Count.");
|
||||
foreach (DataGridColumn column in this.ColumnsInternal.GetDisplayedColumns(c => c.IsVisible && !c.IsReadOnly))
|
||||
{
|
||||
column.GenerateEditingElementInternal(this.EditingRow.Cells[column.Index], this.EditingRow.DataContext);
|
||||
|
@ -1636,7 +1638,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <returns>A row for the provided index.</returns>
|
||||
private DataGridRow GenerateRow(int rowIndex, int slot, object dataContext)
|
||||
{
|
||||
Debug.Assert(rowIndex >= 0, "Expected positive rowIndex.");
|
||||
DiagnosticsDebug.Assert(rowIndex >= 0, "Expected positive rowIndex.");
|
||||
DataGridRow dataGridRow = GetGeneratedRow(dataContext);
|
||||
if (dataGridRow == null)
|
||||
{
|
||||
|
@ -1661,8 +1663,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private DataGridRowGroupHeader GenerateRowGroupHeader(int slot, DataGridRowGroupInfo rowGroupInfo)
|
||||
{
|
||||
Debug.Assert(slot >= 0, "Expected positive slot.");
|
||||
Debug.Assert(rowGroupInfo != null, "Expected non-null rowGroupInfo.");
|
||||
DiagnosticsDebug.Assert(slot >= 0, "Expected positive slot.");
|
||||
DiagnosticsDebug.Assert(rowGroupInfo != null, "Expected non-null rowGroupInfo.");
|
||||
|
||||
DataGridRowGroupHeader groupHeader = this.DisplayData.GetUsedGroupHeader() ?? new DataGridRowGroupHeader();
|
||||
groupHeader.OwningGrid = this;
|
||||
|
@ -1671,7 +1673,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
groupHeader.Level = rowGroupInfo.Level;
|
||||
|
||||
#if FEATURE_ICOLLECTIONVIEW_GROUP
|
||||
Debug.Assert(this.DataConnection.CollectionView != null && groupHeader.Level < this.DataConnection.CollectionView.GroupDescriptions.Count);
|
||||
DiagnosticsDebug.Assert(this.DataConnection.CollectionView != null && groupHeader.Level < this.DataConnection.CollectionView.GroupDescriptions.Count);
|
||||
PropertyGroupDescription propertyGroupDescription = this.DataConnection.CollectionView.GroupDescriptions[groupHeader.Level] as PropertyGroupDescription;
|
||||
if (propertyGroupDescription != null)
|
||||
{
|
||||
|
@ -1728,18 +1730,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <returns>Exact row height with gridlines thickness.</returns>
|
||||
private double GetExactSlotElementHeight(int slot)
|
||||
{
|
||||
Debug.Assert(slot >= 0, "Expected positive slot.");
|
||||
Debug.Assert(slot < this.SlotCount, "Expected slot smaller than SlotCount.");
|
||||
DiagnosticsDebug.Assert(slot >= 0, "Expected positive slot.");
|
||||
DiagnosticsDebug.Assert(slot < this.SlotCount, "Expected slot smaller than SlotCount.");
|
||||
|
||||
if (this.IsSlotVisible(slot))
|
||||
{
|
||||
Debug.Assert(this.DisplayData.GetDisplayedElement(slot) != null, "Expected non-null DisplayData.GetDisplayedElement(slot).");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.GetDisplayedElement(slot) != null, "Expected non-null DisplayData.GetDisplayedElement(slot).");
|
||||
return this.DisplayData.GetDisplayedElement(slot).EnsureMeasured().DesiredSize.Height;
|
||||
}
|
||||
|
||||
// InsertDisplayedElement automatically measures the element
|
||||
FrameworkElement slotElement = InsertDisplayedElement(slot, true /*updateSlotInformation*/);
|
||||
Debug.Assert(slotElement != null, "Expected non-null slotElement.");
|
||||
DiagnosticsDebug.Assert(slotElement != null, "Expected non-null slotElement.");
|
||||
return slotElement.DesiredSize.Height;
|
||||
}
|
||||
|
||||
|
@ -1807,11 +1809,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <returns>Exact height of displayed slot, or default height otherwise.</returns>
|
||||
private double GetSlotElementHeight(int slot)
|
||||
{
|
||||
Debug.Assert(slot >= 0, "Expected positive slot.");
|
||||
Debug.Assert(slot < this.SlotCount, "Expected slot smaller than SlotCount.");
|
||||
DiagnosticsDebug.Assert(slot >= 0, "Expected positive slot.");
|
||||
DiagnosticsDebug.Assert(slot < this.SlotCount, "Expected slot smaller than SlotCount.");
|
||||
if (this.IsSlotVisible(slot))
|
||||
{
|
||||
Debug.Assert(this.DisplayData.GetDisplayedElement(slot) != null, "Expected non-null DisplayData.GetDisplayedElement(slot).");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.GetDisplayedElement(slot) != null, "Expected non-null DisplayData.GetDisplayedElement(slot).");
|
||||
return this.DisplayData.GetDisplayedElement(slot).EnsureMeasured().DesiredSize.Height;
|
||||
}
|
||||
else
|
||||
|
@ -1834,7 +1836,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <returns>Cumulated approximate height of the non-collapsed slots from fromSlot to toSlot inclusive including the potential gridline thickness.</returns>
|
||||
private double GetSlotElementsHeight(int fromSlot, int toSlot)
|
||||
{
|
||||
Debug.Assert(toSlot >= fromSlot, "Expected toSlot greater or equal to fromSlot.");
|
||||
DiagnosticsDebug.Assert(toSlot >= fromSlot, "Expected toSlot greater or equal to fromSlot.");
|
||||
|
||||
double height = 0;
|
||||
for (int slot = GetNextVisibleSlot(fromSlot - 1); slot <= toSlot; slot = GetNextVisibleSlot(slot))
|
||||
|
@ -1911,10 +1913,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
// We can only support creating new rows that are adjacent to the currently visible rows
|
||||
// since they need to be added to the visual tree for us to Measure them.
|
||||
Debug.Assert(
|
||||
DiagnosticsDebug.Assert(
|
||||
this.DisplayData.FirstScrollingSlot == -1 || (slot >= GetPreviousVisibleSlot(this.DisplayData.FirstScrollingSlot) && slot <= GetNextVisibleSlot(this.DisplayData.LastScrollingSlot)),
|
||||
"Expected DisplayData.FirstScrollingSlot equals -1 or (slot greater than or equal to GetPreviousVisibleSlot(DisplayData.FirstScrollingSlot) and slot smaller than or equal to GetNextVisibleSlot(DisplayData.LastScrollingSlot)).");
|
||||
Debug.Assert(element != null, "Expected non-null element.");
|
||||
DiagnosticsDebug.Assert(element != null, "Expected non-null element.");
|
||||
|
||||
if (_rowsPresenter != null)
|
||||
{
|
||||
|
@ -1928,14 +1930,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
if (!row.IsRecycled)
|
||||
{
|
||||
Debug.Assert(!_rowsPresenter.Children.Contains(element), "Expected element not contained in _rowsPresenter.Children.");
|
||||
DiagnosticsDebug.Assert(!_rowsPresenter.Children.Contains(element), "Expected element not contained in _rowsPresenter.Children.");
|
||||
_rowsPresenter.Children.Add(row);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
element.Clip = null;
|
||||
Debug.Assert(row.Index == RowIndexFromSlot(slot), "Expected row.Index equals RowIndexFromSlot(slot).");
|
||||
DiagnosticsDebug.Assert(row.Index == RowIndexFromSlot(slot), "Expected row.Index equals RowIndexFromSlot(slot).");
|
||||
if (!_rowsPresenter.Children.Contains(row))
|
||||
{
|
||||
_rowsPresenter.Children.Add(row);
|
||||
|
@ -1945,7 +1947,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
else
|
||||
{
|
||||
groupHeader = element as DataGridRowGroupHeader;
|
||||
Debug.Assert(groupHeader != null, "Expected non-null grouHeader.");
|
||||
DiagnosticsDebug.Assert(groupHeader != null, "Expected non-null grouHeader.");
|
||||
if (groupHeader != null)
|
||||
{
|
||||
groupHeader.TotalIndent = (groupHeader.Level == 0) ? 0 : this.RowGroupSublevelIndents[groupHeader.Level - 1];
|
||||
|
@ -1988,8 +1990,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void InsertElement(int slot, UIElement element, bool updateVerticalScrollBarOnly, bool isCollapsed, bool isRow)
|
||||
{
|
||||
Debug.Assert(slot >= 0, "Expected positive slot.");
|
||||
Debug.Assert(slot <= this.SlotCount, "Expected slot smaller than or equal to SlotCount.");
|
||||
DiagnosticsDebug.Assert(slot >= 0, "Expected positive slot.");
|
||||
DiagnosticsDebug.Assert(slot <= this.SlotCount, "Expected slot smaller than or equal to SlotCount.");
|
||||
|
||||
OnInsertingElement(slot, true /*firstInsertion*/, isCollapsed, isRow); // will throw an exception if the insertion is illegal
|
||||
|
||||
|
@ -2011,7 +2013,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void OnAddedElement_Phase1(int slot, UIElement element)
|
||||
{
|
||||
Debug.Assert(slot >= 0, "Expected positive slot.");
|
||||
DiagnosticsDebug.Assert(slot >= 0, "Expected positive slot.");
|
||||
|
||||
// Row needs to be potentially added to the displayed rows
|
||||
if (SlotIsDisplayed(slot))
|
||||
|
@ -2117,7 +2119,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
// Assume we're adding a new row
|
||||
int rowIndex = this.DataConnection.IndexOf(insertedItem);
|
||||
Debug.Assert(rowIndex != -1, "Expected rowIndex other than -1.");
|
||||
DiagnosticsDebug.Assert(rowIndex != -1, "Expected rowIndex other than -1.");
|
||||
if (this.SlotCount == 0 && this.DataConnection.ShouldAutoGenerateColumns)
|
||||
{
|
||||
AutoGenerateColumnsPrivate();
|
||||
|
@ -2161,10 +2163,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
#endif
|
||||
|
||||
DataGridRowGroupInfo groupInfo = RowGroupInfoFromCollectionViewGroup(removedGroup);
|
||||
Debug.Assert(groupInfo != null, "Expected non-null groupInfo.");
|
||||
DiagnosticsDebug.Assert(groupInfo != null, "Expected non-null groupInfo.");
|
||||
if ((groupInfo.Level == _rowGroupHeightsByLevel.Length - 1) && (removedGroup.GroupItems != null) && (removedGroup.GroupItems.Count > 0))
|
||||
{
|
||||
Debug.Assert(groupInfo.LastSubItemSlot - groupInfo.Slot == removedGroup.GroupItems.Count, "Expected groupInfo.LastSubItemSlot - groupInfo.Slot equals removedGroup.GroupItems.Count.");
|
||||
DiagnosticsDebug.Assert(groupInfo.LastSubItemSlot - groupInfo.Slot == removedGroup.GroupItems.Count, "Expected groupInfo.LastSubItemSlot - groupInfo.Slot equals removedGroup.GroupItems.Count.");
|
||||
|
||||
// If we're removing a leaf Group then remove all of its items before removing the Group.
|
||||
for (int i = 0; i < removedGroup.GroupItems.Count; i++)
|
||||
|
@ -2219,7 +2221,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void OnInsertedElement_Phase1(int slot, UIElement element, bool isCollapsed, bool isRow)
|
||||
{
|
||||
Debug.Assert(slot >= 0, "Expected positive slot.");
|
||||
DiagnosticsDebug.Assert(slot >= 0, "Expected positive slot.");
|
||||
|
||||
// Fix the Index of all following rows
|
||||
CorrectSlotsAfterInsertion(slot, isCollapsed, isRow);
|
||||
|
@ -2231,18 +2233,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
DataGridRow dataGridRow = element as DataGridRow;
|
||||
if (dataGridRow != null)
|
||||
{
|
||||
Debug.Assert(dataGridRow.Cells.Count == this.ColumnsItemsInternal.Count, "Expected dataGridRow.Cells.Count equals ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(dataGridRow.Cells.Count == this.ColumnsItemsInternal.Count, "Expected dataGridRow.Cells.Count equals ColumnsItemsInternal.Count.");
|
||||
|
||||
int columnIndex = 0;
|
||||
foreach (DataGridCell dataGridCell in dataGridRow.Cells)
|
||||
{
|
||||
Debug.Assert(dataGridCell.OwningRow == dataGridRow, "Expected dataGridRow owns dataGridCell.");
|
||||
Debug.Assert(dataGridCell.OwningColumn == this.ColumnsItemsInternal[columnIndex], "Expected ColumnsItemsInternal[columnIndex] owns dataGridCell.");
|
||||
DiagnosticsDebug.Assert(dataGridCell.OwningRow == dataGridRow, "Expected dataGridRow owns dataGridCell.");
|
||||
DiagnosticsDebug.Assert(dataGridCell.OwningColumn == this.ColumnsItemsInternal[columnIndex], "Expected ColumnsItemsInternal[columnIndex] owns dataGridCell.");
|
||||
columnIndex++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Debug.Assert(!isCollapsed, "Expected isCollapsed is false.");
|
||||
DiagnosticsDebug.Assert(!isCollapsed, "Expected isCollapsed is false.");
|
||||
OnAddedElement_Phase1(slot, element);
|
||||
}
|
||||
else if ((slot <= this.DisplayData.FirstScrollingSlot) || (isCollapsed && (slot <= this.DisplayData.LastScrollingSlot)))
|
||||
|
@ -2253,7 +2255,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void OnInsertedElement_Phase2(int slot, bool updateVerticalScrollBarOnly, bool isCollapsed)
|
||||
{
|
||||
Debug.Assert(slot >= 0, "Expected positive slot.");
|
||||
DiagnosticsDebug.Assert(slot >= 0, "Expected positive slot.");
|
||||
|
||||
if (!isCollapsed)
|
||||
{
|
||||
|
@ -2272,7 +2274,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// The underlying data was already added, therefore we need to avoid accessing any back-end data since we might be off by 1 row.
|
||||
_temporarilyResetCurrentCell = true;
|
||||
bool success = SetCurrentCellCore(-1, -1);
|
||||
Debug.Assert(success, "Expected successful SetCurrentCellCore call.");
|
||||
DiagnosticsDebug.Assert(success, "Expected successful SetCurrentCellCore call.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2417,8 +2419,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
private void OnRemovingElement(int slotDeleted)
|
||||
{
|
||||
// Note that the row needs to be deleted no matter what. The underlying data row was already deleted.
|
||||
Debug.Assert(slotDeleted >= 0, "Expected positive slotDeleted.");
|
||||
Debug.Assert(slotDeleted < this.SlotCount, "Expected slotDeleted smaller than SlotCount.");
|
||||
DiagnosticsDebug.Assert(slotDeleted >= 0, "Expected positive slotDeleted.");
|
||||
DiagnosticsDebug.Assert(slotDeleted < this.SlotCount, "Expected slotDeleted smaller than SlotCount.");
|
||||
_temporarilyResetCurrentCell = false;
|
||||
|
||||
// Reset the current cell's address if it's on the deleted row, or after it.
|
||||
|
@ -2429,14 +2431,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
// No editing is committed since the underlying entity was already deleted.
|
||||
bool success = SetCurrentCellCore(-1, -1, false /*commitEdit*/, false /*endRowEdit*/);
|
||||
Debug.Assert(success, "Expected successful SetCurrentCellCore call.");
|
||||
DiagnosticsDebug.Assert(success, "Expected successful SetCurrentCellCore call.");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Underlying data of deleted row is gone. It cannot be accessed anymore. Skip the commit of the editing.
|
||||
_temporarilyResetCurrentCell = true;
|
||||
bool success = SetCurrentCellCore(-1, -1);
|
||||
Debug.Assert(success, "Expected successful SetCurrentCellCore call.");
|
||||
DiagnosticsDebug.Assert(success, "Expected successful SetCurrentCellCore call.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2631,8 +2633,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void RemoveDisplayedElement(int slot, bool wasDeleted, bool updateSlotInformation)
|
||||
{
|
||||
Debug.Assert(slot >= this.DisplayData.FirstScrollingSlot, "Expected slot larger or equal to DisplayData.FirstScrollingSlot.");
|
||||
Debug.Assert(slot <= this.DisplayData.LastScrollingSlot, "Expected slot smaller or equal to DisplayData.LastScrollingSlot.");
|
||||
DiagnosticsDebug.Assert(slot >= this.DisplayData.FirstScrollingSlot, "Expected slot larger or equal to DisplayData.FirstScrollingSlot.");
|
||||
DiagnosticsDebug.Assert(slot <= this.DisplayData.LastScrollingSlot, "Expected slot smaller or equal to DisplayData.LastScrollingSlot.");
|
||||
|
||||
RemoveDisplayedElement(this.DisplayData.GetDisplayedElement(slot), slot, wasDeleted, updateSlotInformation);
|
||||
}
|
||||
|
@ -2686,7 +2688,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
if (this.EditingRow != null && this.EditingRow.Cells != null)
|
||||
{
|
||||
Debug.Assert(this.EditingRow.Cells.Count == this.ColumnsItemsInternal.Count, "Expected EditingRow.Cells.Count equals ColumnsItemsInternal.Count.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow.Cells.Count == this.ColumnsItemsInternal.Count, "Expected EditingRow.Cells.Count equals ColumnsItemsInternal.Count.");
|
||||
foreach (DataGridColumn column in this.Columns)
|
||||
{
|
||||
column.RemoveEditingElement();
|
||||
|
@ -2696,8 +2698,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void RemoveElementAt(int slot, object item, bool isRow)
|
||||
{
|
||||
Debug.Assert(slot >= 0, "Expected positive slot.");
|
||||
Debug.Assert(slot < this.SlotCount, "Expected slot smaller than SlotCount.");
|
||||
DiagnosticsDebug.Assert(slot >= 0, "Expected positive slot.");
|
||||
DiagnosticsDebug.Assert(slot < this.SlotCount, "Expected slot smaller than SlotCount.");
|
||||
|
||||
OnRemovingElement(slot);
|
||||
|
||||
|
@ -2775,7 +2777,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
/// <returns>True when the slot is displayed.</returns>
|
||||
private bool SlotIsDisplayed(int slot)
|
||||
{
|
||||
Debug.Assert(slot >= 0, "Expected positive slot.");
|
||||
DiagnosticsDebug.Assert(slot >= 0, "Expected positive slot.");
|
||||
|
||||
if (slot >= this.DisplayData.FirstScrollingSlot &&
|
||||
slot <= this.DisplayData.LastScrollingSlot)
|
||||
|
@ -2804,8 +2806,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// Updates display information and displayed rows after scrolling the given number of pixels
|
||||
private void ScrollSlotsByHeight(double height)
|
||||
{
|
||||
Debug.Assert(this.DisplayData.FirstScrollingSlot >= 0, "Expected positive DisplayData.FirstScrollingSlot.");
|
||||
Debug.Assert(!DoubleUtil.IsZero(height), "DoubleUtil.IsZero(height) is false.");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.FirstScrollingSlot >= 0, "Expected positive DisplayData.FirstScrollingSlot.");
|
||||
DiagnosticsDebug.Assert(!DoubleUtil.IsZero(height), "DoubleUtil.IsZero(height) is false.");
|
||||
|
||||
_scrollingByHeight = true;
|
||||
try
|
||||
|
@ -2979,7 +2981,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
if (newFirstScrollingSlot < this.SlotCount - 1)
|
||||
{
|
||||
newFirstScrollingSlot = GetNextVisibleSlot(newFirstScrollingSlot);
|
||||
Debug.Assert(newFirstScrollingSlot != -1, "Expected newFirstScrollingSlot other than -1.");
|
||||
DiagnosticsDebug.Assert(newFirstScrollingSlot != -1, "Expected newFirstScrollingSlot other than -1.");
|
||||
}
|
||||
|
||||
this.NegVerticalOffset = 0;
|
||||
|
@ -3017,8 +3019,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
}
|
||||
|
||||
Debug.Assert(this.DisplayData.FirstScrollingSlot >= 0, "Expected positive DisplayData.FirstScrollingSlot.");
|
||||
Debug.Assert(GetExactSlotElementHeight(this.DisplayData.FirstScrollingSlot) > this.NegVerticalOffset, "Expected GetExactSlotElementHeight(DisplayData.FirstScrollingSlot) larger than this.NegVerticalOffset.");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.FirstScrollingSlot >= 0, "Expected positive DisplayData.FirstScrollingSlot.");
|
||||
DiagnosticsDebug.Assert(GetExactSlotElementHeight(this.DisplayData.FirstScrollingSlot) > this.NegVerticalOffset, "Expected GetExactSlotElementHeight(DisplayData.FirstScrollingSlot) larger than this.NegVerticalOffset.");
|
||||
|
||||
if (this.DisplayData.FirstScrollingSlot == 0)
|
||||
{
|
||||
|
@ -3036,7 +3038,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
VerticalOffset = newVerticalOffset;
|
||||
}
|
||||
|
||||
Debug.Assert(
|
||||
DiagnosticsDebug.Assert(
|
||||
_verticalOffset != 0 || this.NegVerticalOffset != 0 || this.DisplayData.FirstScrollingSlot <= 0,
|
||||
"Expected _verticalOffset other than 0 or this.NegVerticalOffset other than 0 or this.DisplayData.FirstScrollingSlot smaller than or equal to 0.");
|
||||
|
||||
|
@ -3044,8 +3046,8 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
this.DisplayData.FullyRecycleElements();
|
||||
|
||||
Debug.Assert(DoubleUtil.GreaterThanOrClose(this.NegVerticalOffset, 0), "Expected NegVerticalOffset greater than or close to 0.");
|
||||
Debug.Assert(DoubleUtil.GreaterThanOrClose(_verticalOffset, this.NegVerticalOffset), "Expected _verticalOffset greater than or close to NegVerticalOffset.");
|
||||
DiagnosticsDebug.Assert(DoubleUtil.GreaterThanOrClose(this.NegVerticalOffset, 0), "Expected NegVerticalOffset greater than or close to 0.");
|
||||
DiagnosticsDebug.Assert(DoubleUtil.GreaterThanOrClose(_verticalOffset, this.NegVerticalOffset), "Expected _verticalOffset greater than or close to NegVerticalOffset.");
|
||||
|
||||
DataGridAutomationPeer peer = DataGridAutomationPeer.FromElement(this) as DataGridAutomationPeer;
|
||||
if (peer != null)
|
||||
|
@ -3061,7 +3063,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void SelectDisplayedElement(int slot)
|
||||
{
|
||||
Debug.Assert(IsSlotVisible(slot), "Expected IsSlotVisible(slot) is true.");
|
||||
DiagnosticsDebug.Assert(IsSlotVisible(slot), "Expected IsSlotVisible(slot) is true.");
|
||||
FrameworkElement element = this.DisplayData.GetDisplayedElement(slot) as FrameworkElement;
|
||||
DataGridRow row = this.DisplayData.GetDisplayedElement(slot) as DataGridRow;
|
||||
if (row != null)
|
||||
|
@ -3192,9 +3194,9 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void UnloadRow(DataGridRow dataGridRow)
|
||||
{
|
||||
Debug.Assert(dataGridRow != null, "Expected non-null dataGridRow.");
|
||||
Debug.Assert(_rowsPresenter != null, "Expected non-null _rowsPresenter.");
|
||||
Debug.Assert(_rowsPresenter.Children.Contains(dataGridRow), "Expected dataGridRow contained in _rowsPresenter.Children.");
|
||||
DiagnosticsDebug.Assert(dataGridRow != null, "Expected non-null dataGridRow.");
|
||||
DiagnosticsDebug.Assert(_rowsPresenter != null, "Expected non-null _rowsPresenter.");
|
||||
DiagnosticsDebug.Assert(_rowsPresenter.Children.Contains(dataGridRow), "Expected dataGridRow contained in _rowsPresenter.Children.");
|
||||
|
||||
if (_loadedRows.Contains(dataGridRow))
|
||||
{
|
||||
|
@ -3224,7 +3226,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
private void UpdateDisplayedRows(int newFirstDisplayedSlot, double displayHeight)
|
||||
{
|
||||
Debug.Assert(!_collapsedSlotsTable.Contains(newFirstDisplayedSlot), "Expected newFirstDisplayedSlot not contained in _collapsedSlotsTable.");
|
||||
DiagnosticsDebug.Assert(!_collapsedSlotsTable.Contains(newFirstDisplayedSlot), "Expected newFirstDisplayedSlot not contained in _collapsedSlotsTable.");
|
||||
|
||||
int firstDisplayedScrollingSlot = newFirstDisplayedSlot;
|
||||
int lastDisplayedScrollingSlot = -1;
|
||||
|
@ -3282,18 +3284,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
if (visibleScrollingRows == 0)
|
||||
{
|
||||
firstDisplayedScrollingSlot = -1;
|
||||
Debug.Assert(lastDisplayedScrollingSlot == -1, "Expected lastDisplayedScrollingSlot equal to -1.");
|
||||
DiagnosticsDebug.Assert(lastDisplayedScrollingSlot == -1, "Expected lastDisplayedScrollingSlot equal to -1.");
|
||||
}
|
||||
|
||||
Debug.Assert(lastDisplayedScrollingSlot < this.SlotCount, "lastDisplayedScrollingRow larger than number of rows");
|
||||
DiagnosticsDebug.Assert(lastDisplayedScrollingSlot < this.SlotCount, "lastDisplayedScrollingRow larger than number of rows");
|
||||
|
||||
RemoveNonDisplayedRows(firstDisplayedScrollingSlot, lastDisplayedScrollingSlot);
|
||||
|
||||
Debug.Assert(this.DisplayData.NumDisplayedScrollingElements >= 0, "the number of visible scrolling rows can't be negative");
|
||||
Debug.Assert(this.DisplayData.NumTotallyDisplayedScrollingElements >= 0, "the number of totally visible scrolling rows can't be negative");
|
||||
Debug.Assert(this.DisplayData.FirstScrollingSlot < this.SlotCount, "firstDisplayedScrollingRow larger than number of rows");
|
||||
Debug.Assert(this.DisplayData.FirstScrollingSlot == firstDisplayedScrollingSlot, "Expected DisplayData.FirstScrollingSlot equal to firstDisplayedScrollingSlot.");
|
||||
Debug.Assert(this.DisplayData.LastScrollingSlot == lastDisplayedScrollingSlot, "DisplayData.LastScrollingSlot equal to lastDisplayedScrollingSlot.");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.NumDisplayedScrollingElements >= 0, "the number of visible scrolling rows can't be negative");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.NumTotallyDisplayedScrollingElements >= 0, "the number of totally visible scrolling rows can't be negative");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.FirstScrollingSlot < this.SlotCount, "firstDisplayedScrollingRow larger than number of rows");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.FirstScrollingSlot == firstDisplayedScrollingSlot, "Expected DisplayData.FirstScrollingSlot equal to firstDisplayedScrollingSlot.");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.LastScrollingSlot == lastDisplayedScrollingSlot, "DisplayData.LastScrollingSlot equal to lastDisplayedScrollingSlot.");
|
||||
}
|
||||
|
||||
// Similar to UpdateDisplayedRows except that it starts with the LastDisplayedScrollingRow
|
||||
|
@ -3301,7 +3303,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
// when scrolling down to a full row
|
||||
private void UpdateDisplayedRowsFromBottom(int newLastDisplayedScrollingRow)
|
||||
{
|
||||
Debug.Assert(!_collapsedSlotsTable.Contains(newLastDisplayedScrollingRow), "Expected newLastDisplayedScrollingRow not contained in _collapsedSlotsTable.");
|
||||
DiagnosticsDebug.Assert(!_collapsedSlotsTable.Contains(newLastDisplayedScrollingRow), "Expected newLastDisplayedScrollingRow not contained in _collapsedSlotsTable.");
|
||||
|
||||
int lastDisplayedScrollingRow = newLastDisplayedScrollingRow;
|
||||
int firstDisplayedScrollingRow = -1;
|
||||
|
@ -3331,16 +3333,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
this.DisplayData.NumTotallyDisplayedScrollingElements = deltaY > displayHeight ? visibleScrollingRows - 1 : visibleScrollingRows;
|
||||
|
||||
Debug.Assert(this.DisplayData.NumTotallyDisplayedScrollingElements >= 0, "Expected positive DisplayData.NumTotallyDisplayedScrollingElements.");
|
||||
Debug.Assert(lastDisplayedScrollingRow < this.SlotCount, "lastDisplayedScrollingRow larger than number of rows");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.NumTotallyDisplayedScrollingElements >= 0, "Expected positive DisplayData.NumTotallyDisplayedScrollingElements.");
|
||||
DiagnosticsDebug.Assert(lastDisplayedScrollingRow < this.SlotCount, "lastDisplayedScrollingRow larger than number of rows");
|
||||
|
||||
this.NegVerticalOffset = Math.Max(0, deltaY - displayHeight);
|
||||
|
||||
RemoveNonDisplayedRows(firstDisplayedScrollingRow, lastDisplayedScrollingRow);
|
||||
|
||||
Debug.Assert(this.DisplayData.NumDisplayedScrollingElements >= 0, "the number of visible scrolling rows can't be negative");
|
||||
Debug.Assert(this.DisplayData.NumTotallyDisplayedScrollingElements >= 0, "the number of totally visible scrolling rows can't be negative");
|
||||
Debug.Assert(this.DisplayData.FirstScrollingSlot < this.SlotCount, "firstDisplayedScrollingRow larger than number of rows");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.NumDisplayedScrollingElements >= 0, "the number of visible scrolling rows can't be negative");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.NumTotallyDisplayedScrollingElements >= 0, "the number of totally visible scrolling rows can't be negative");
|
||||
DiagnosticsDebug.Assert(this.DisplayData.FirstScrollingSlot < this.SlotCount, "firstDisplayedScrollingRow larger than number of rows");
|
||||
}
|
||||
|
||||
private void UpdateRowDetailsHeightEstimate()
|
||||
|
@ -3425,7 +3427,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
endSlot--;
|
||||
}
|
||||
|
||||
Debug.Assert(endSlot >= 0, "Expected positive endSlot.");
|
||||
DiagnosticsDebug.Assert(endSlot >= 0, "Expected positive endSlot.");
|
||||
foreach (int slot in this.RowGroupHeadersTable.GetIndexes(targetRowGroupInfo.Slot + 1))
|
||||
{
|
||||
DataGridRowGroupInfo rowGroupInfo = this.RowGroupHeadersTable.GetValueAt(slot);
|
||||
|
@ -3451,7 +3453,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
int elementsToRemove = endDisplayedSlot - startDisplayedSlot + 1 - _collapsedSlotsTable.GetIndexCount(startDisplayedSlot, endDisplayedSlot);
|
||||
if (_focusedRow != null && _focusedRow.Slot >= startSlot && _focusedRow.Slot <= endSlot)
|
||||
{
|
||||
Debug.Assert(this.EditingRow == null, "Expected null EditingRow.");
|
||||
DiagnosticsDebug.Assert(this.EditingRow == null, "Expected null EditingRow.");
|
||||
|
||||
// Don't call ResetFocusedRow here because we're already cleaning it up below, and we don't want to FullyRecycle yet
|
||||
_focusedRow = null;
|
||||
|
@ -3486,7 +3488,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
{
|
||||
// Our first visible slot was collapsed, find the replacement
|
||||
int collapsedSlotsAbove = this.DisplayData.FirstScrollingSlot - startSlot - _collapsedSlotsTable.GetIndexCount(startSlot, this.DisplayData.FirstScrollingSlot);
|
||||
Debug.Assert(collapsedSlotsAbove > 0, "Expected positive collapsedSlotsAbove.");
|
||||
DiagnosticsDebug.Assert(collapsedSlotsAbove > 0, "Expected positive collapsedSlotsAbove.");
|
||||
int newFirstScrollingSlot = GetNextVisibleSlot(this.DisplayData.FirstScrollingSlot);
|
||||
while (collapsedSlotsAbove > 1 && newFirstScrollingSlot < this.SlotCount)
|
||||
{
|
||||
|
|
|
@ -12,6 +12,8 @@ using Windows.UI.Xaml.Controls;
|
|||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -64,7 +66,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
DataGridRow row = element as DataGridRow;
|
||||
if (row != null)
|
||||
{
|
||||
Debug.Assert(row.Index != -1, "Expected Index other than -1."); // A displayed row should always have its index
|
||||
DiagnosticsDebug.Assert(row.Index != -1, "Expected Index other than -1."); // A displayed row should always have its index
|
||||
|
||||
// Visibility for all filler cells needs to be set in one place. Setting it individually in
|
||||
// each CellsPresenter causes an NxN layout cycle (see DevDiv Bugs 211557)
|
||||
|
@ -180,7 +182,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls.Primitives
|
|||
{
|
||||
if (this.OwningGrid != null)
|
||||
{
|
||||
Debug.Assert(this.OwningGrid.IsEnabled, "Expected OwningGrid.IsEnabled is true.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid.IsEnabled, "Expected OwningGrid.IsEnabled is true.");
|
||||
|
||||
_preManipulationHorizontalOffset = this.OwningGrid.HorizontalOffset;
|
||||
_preManipulationVerticalOffset = this.OwningGrid.VerticalOffset;
|
||||
|
|
|
@ -10,6 +10,8 @@ using Microsoft.Toolkit.Uwp.UI.Controls.DataGridInternals;
|
|||
using Microsoft.Toolkit.Uwp.Utilities;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
using DiagnosticsDebug = System.Diagnostics.Debug;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Controls
|
||||
{
|
||||
internal class DataGridSelectedItemsCollection : IList
|
||||
|
@ -38,7 +40,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
|
||||
int slot = _selectedSlotsTable.GetNthIndex(index);
|
||||
Debug.Assert(slot >= 0, "Expected positive slot.");
|
||||
DiagnosticsDebug.Assert(slot >= 0, "Expected positive slot.");
|
||||
return this.OwningGrid.DataConnection.GetDataItem(this.OwningGrid.RowIndexFromSlot(slot));
|
||||
}
|
||||
|
||||
|
@ -77,7 +79,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
throw DataGridError.DataGrid.ItemIsNotContainedInTheItemsSource("dataItem");
|
||||
}
|
||||
|
||||
Debug.Assert(itemIndex >= 0, "Expected positive itemIndex.");
|
||||
DiagnosticsDebug.Assert(itemIndex >= 0, "Expected positive itemIndex.");
|
||||
|
||||
int slot = this.OwningGrid.SlotFromRowIndex(itemIndex);
|
||||
if (_selectedSlotsTable.RangeCount == 0)
|
||||
|
@ -120,7 +122,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return false;
|
||||
}
|
||||
|
||||
Debug.Assert(itemIndex >= 0, "Expected positive itemIndex.");
|
||||
DiagnosticsDebug.Assert(itemIndex >= 0, "Expected positive itemIndex.");
|
||||
|
||||
return ContainsSlot(this.OwningGrid.SlotFromRowIndex(itemIndex));
|
||||
}
|
||||
|
@ -133,7 +135,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return -1;
|
||||
}
|
||||
|
||||
Debug.Assert(itemIndex >= 0, "Expected positive itemIndex.");
|
||||
DiagnosticsDebug.Assert(itemIndex >= 0, "Expected positive itemIndex.");
|
||||
|
||||
int slot = this.OwningGrid.SlotFromRowIndex(itemIndex);
|
||||
return _selectedSlotsTable.IndexOf(slot);
|
||||
|
@ -157,7 +159,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
return;
|
||||
}
|
||||
|
||||
Debug.Assert(itemIndex >= 0, "Expected positive itemIndex.");
|
||||
DiagnosticsDebug.Assert(itemIndex >= 0, "Expected positive itemIndex.");
|
||||
|
||||
if (itemIndex == this.OwningGrid.CurrentSlot &&
|
||||
!this.OwningGrid.CommitEdit(DataGridEditingUnit.Row, true /*exitEditing*/))
|
||||
|
@ -182,7 +184,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
}
|
||||
|
||||
int rowIndex = _selectedSlotsTable.GetNthIndex(index);
|
||||
Debug.Assert(rowIndex > -1, "Expected positive itemIndex.");
|
||||
DiagnosticsDebug.Assert(rowIndex > -1, "Expected positive itemIndex.");
|
||||
|
||||
if (rowIndex == this.OwningGrid.CurrentSlot &&
|
||||
!this.OwningGrid.CommitEdit(DataGridEditingUnit.Row, true /*exitEditing*/))
|
||||
|
@ -226,14 +228,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
|
|||
|
||||
public IEnumerator GetEnumerator()
|
||||
{
|
||||
Debug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
Debug.Assert(this.OwningGrid.DataConnection != null, "Expected non-null owning DataGrid.DataConnection.");
|
||||
Debug.Assert(_selectedSlotsTable != null, "Expected non-null _selectedSlotsTable.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid != null, "Expected non-null owning DataGrid.");
|
||||
DiagnosticsDebug.Assert(this.OwningGrid.DataConnection != null, "Expected non-null owning DataGrid.DataConnection.");
|
||||
DiagnosticsDebug.Assert(_selectedSlotsTable != null, "Expected non-null _selectedSlotsTable.");
|
||||
|
||||
foreach (int slot in _selectedSlotsTable.GetIndexes())
|
||||
{
|
||||
int rowIndex = this.OwningGrid.RowIndexFromSlot(slot);
|
||||
Debug.Assert(rowIndex > -1, "Expected positive rowIndex.");
|
||||
DiagnosticsDebug.Assert(rowIndex > -1, "Expected positive rowIndex.");
|
||||
yield return this.OwningGrid.DataConnection.GetDataItem(rowIndex);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче