Browse Source
Merge pull request #4872 from YohDeadfall/various-nullability-issues
Fixed invalid cast issue if source isn't visual and nullability warnings
pull/4884/head
Dariusz Komosiński
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
5 additions and
9 deletions
-
src/Avalonia.Controls/Primitives/SelectingItemsControl.cs
|
|
|
@ -354,19 +354,15 @@ namespace Avalonia.Controls.Primitives |
|
|
|
/// </summary>
|
|
|
|
/// <param name="eventSource">The control that raised the event.</param>
|
|
|
|
/// <returns>The container or null if the event did not originate in a container.</returns>
|
|
|
|
protected IControl? GetContainerFromEventSource(IInteractive eventSource) |
|
|
|
protected IControl? GetContainerFromEventSource(IInteractive? eventSource) |
|
|
|
{ |
|
|
|
var parent = (IVisual)eventSource; |
|
|
|
|
|
|
|
while (parent != null) |
|
|
|
for (var current = eventSource as IVisual; current != null; current = current.VisualParent) |
|
|
|
{ |
|
|
|
if (parent is IControl control && control.LogicalParent == this |
|
|
|
&& ItemContainerGenerator?.IndexFromContainer(control) != -1) |
|
|
|
if (current is IControl control && control.LogicalParent == this && |
|
|
|
ItemContainerGenerator?.IndexFromContainer(control) != -1) |
|
|
|
{ |
|
|
|
return control; |
|
|
|
} |
|
|
|
|
|
|
|
parent = parent.VisualParent; |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
@ -670,7 +666,7 @@ namespace Avalonia.Controls.Primitives |
|
|
|
/// false.
|
|
|
|
/// </returns>
|
|
|
|
protected bool UpdateSelectionFromEventSource( |
|
|
|
IInteractive eventSource, |
|
|
|
IInteractive? eventSource, |
|
|
|
bool select = true, |
|
|
|
bool rangeModifier = false, |
|
|
|
bool toggleModifier = false, |
|
|
|
|