-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10055 from AvaloniaUI/fixes/9997-nth-last-child-i…
…temscontrol Fix nth-last-child styles on virtualizing layouts
- Loading branch information
Showing
13 changed files
with
196 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 60 additions & 9 deletions
69
src/Avalonia.Base/LogicalTree/ChildIndexChangedEventArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,79 @@ | ||
#nullable enable | ||
using System; | ||
using System; | ||
|
||
#nullable enable | ||
|
||
namespace Avalonia.LogicalTree | ||
{ | ||
/// <summary> | ||
/// Describes the action that caused a <see cref="IChildIndexProvider.ChildIndexChanged"/> event. | ||
/// </summary> | ||
public enum ChildIndexChangedAction | ||
{ | ||
/// <summary> | ||
/// The index of a single child changed. | ||
/// </summary> | ||
ChildIndexChanged, | ||
|
||
/// <summary> | ||
/// The index of multiple children changed and all children should be re-evaluated. | ||
/// </summary> | ||
ChildIndexesReset, | ||
|
||
/// <summary> | ||
/// The total number of children changed. | ||
/// </summary> | ||
TotalCountChanged, | ||
} | ||
|
||
/// <summary> | ||
/// Event args for <see cref="IChildIndexProvider.ChildIndexChanged"/> event. | ||
/// </summary> | ||
public class ChildIndexChangedEventArgs : EventArgs | ||
{ | ||
public static new ChildIndexChangedEventArgs Empty { get; } = new ChildIndexChangedEventArgs(); | ||
|
||
private ChildIndexChangedEventArgs() | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ChildIndexChangedEventArgs"/> class with | ||
/// an action of <see cref="ChildIndexChangedAction.ChildIndexChanged"/>. | ||
/// </summary> | ||
/// <param name="child">The child whose index was changed.</param> | ||
/// <param name="index">The new index of the child.</param> | ||
public ChildIndexChangedEventArgs(ILogical child, int index) | ||
{ | ||
Action = ChildIndexChangedAction.ChildIndexChanged; | ||
Child = child; | ||
Index = index; | ||
} | ||
|
||
public ChildIndexChangedEventArgs(ILogical child) | ||
private ChildIndexChangedEventArgs(ChildIndexChangedAction action) | ||
{ | ||
Child = child; | ||
Action = action; | ||
Index = -1; | ||
} | ||
|
||
/// <summary> | ||
/// Logical child which index was changed. | ||
/// If null, all children should be reset. | ||
/// Gets the type of change action that ocurred on the list control. | ||
/// </summary> | ||
public ChildIndexChangedAction Action { get; } | ||
|
||
/// <summary> | ||
/// Gets the logical child whose index was changed or null if all children should be re-evaluated. | ||
/// </summary> | ||
public ILogical? Child { get; } | ||
|
||
/// <summary> | ||
/// Gets the new index of <see cref="Child"/> or -1 if all children should be re-evaluated. | ||
/// </summary> | ||
public int Index { get; } | ||
|
||
/// <summary> | ||
/// Gets an instance of the <see cref="ChildIndexChangedEventArgs"/> with an action of | ||
/// <see cref="ChildIndexChangedAction.ChildIndexesReset"/>. | ||
/// </summary> | ||
public static ChildIndexChangedEventArgs ChildIndexesReset { get; } = new(ChildIndexChangedAction.ChildIndexesReset); | ||
|
||
/// <summary> | ||
/// Gets an instance of the <see cref="ChildIndexChangedEventArgs"/> with an action of | ||
/// <see cref="ChildIndexChangedAction.TotalCountChanged"/>. | ||
/// </summary> | ||
public static ChildIndexChangedEventArgs TotalCountChanged { get; } = new(ChildIndexChangedAction.TotalCountChanged); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.