|
@@ -84,16 +84,16 @@ namespace Avalonia.Controls
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Defines the <see cref="Expanded"/> event.
|
|
/// Defines the <see cref="Expanded"/> event.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- public static readonly RoutedEvent<RoutedEventArgs> ExpandedEvent =
|
|
|
|
|
- RoutedEvent.Register<Expander, RoutedEventArgs>(
|
|
|
|
|
|
|
+ public static readonly RoutedEvent<CancelRoutedEventArgs> ExpandedEvent =
|
|
|
|
|
+ RoutedEvent.Register<Expander, CancelRoutedEventArgs>(
|
|
|
nameof(Expanded),
|
|
nameof(Expanded),
|
|
|
RoutingStrategies.Bubble);
|
|
RoutingStrategies.Bubble);
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Defines the <see cref="Expanding"/> event.
|
|
/// Defines the <see cref="Expanding"/> event.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- public static readonly RoutedEvent<RoutedEventArgs> ExpandingEvent =
|
|
|
|
|
- RoutedEvent.Register<Expander, RoutedEventArgs>(
|
|
|
|
|
|
|
+ public static readonly RoutedEvent<CancelRoutedEventArgs> ExpandingEvent =
|
|
|
|
|
+ RoutedEvent.Register<Expander, CancelRoutedEventArgs>(
|
|
|
nameof(Expanding),
|
|
nameof(Expanding),
|
|
|
RoutingStrategies.Bubble);
|
|
RoutingStrategies.Bubble);
|
|
|
|
|
|
|
@@ -149,10 +149,10 @@ namespace Avalonia.Controls
|
|
|
/// Occurs as the content area is closing.
|
|
/// Occurs as the content area is closing.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <remarks>
|
|
/// <remarks>
|
|
|
- /// The event args <see cref="RoutedEventArgs.Handled"/> property may be set to true to cancel the event
|
|
|
|
|
|
|
+ /// The event args <see cref="CancelRoutedEventArgs.Cancel"/> property may be set to true to cancel the event
|
|
|
/// and keep the control open (expanded).
|
|
/// and keep the control open (expanded).
|
|
|
/// </remarks>
|
|
/// </remarks>
|
|
|
- public event EventHandler<RoutedEventArgs>? Collapsing
|
|
|
|
|
|
|
+ public event EventHandler<CancelRoutedEventArgs>? Collapsing
|
|
|
{
|
|
{
|
|
|
add => AddHandler(CollapsingEvent, value);
|
|
add => AddHandler(CollapsingEvent, value);
|
|
|
remove => RemoveHandler(CollapsingEvent, value);
|
|
remove => RemoveHandler(CollapsingEvent, value);
|
|
@@ -171,10 +171,10 @@ namespace Avalonia.Controls
|
|
|
/// Occurs as the content area is opening.
|
|
/// Occurs as the content area is opening.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
/// <remarks>
|
|
/// <remarks>
|
|
|
- /// The event args <see cref="RoutedEventArgs.Handled"/> property may be set to true to cancel the event
|
|
|
|
|
|
|
+ /// The event args <see cref="CancelRoutedEventArgs.Cancel"/> property may be set to true to cancel the event
|
|
|
/// and keep the control closed (collapsed).
|
|
/// and keep the control closed (collapsed).
|
|
|
/// </remarks>
|
|
/// </remarks>
|
|
|
- public event EventHandler<RoutedEventArgs>? Expanding
|
|
|
|
|
|
|
+ public event EventHandler<CancelRoutedEventArgs>? Expanding
|
|
|
{
|
|
{
|
|
|
add => AddHandler(ExpandingEvent, value);
|
|
add => AddHandler(ExpandingEvent, value);
|
|
|
remove => RemoveHandler(ExpandingEvent, value);
|
|
remove => RemoveHandler(ExpandingEvent, value);
|
|
@@ -295,22 +295,22 @@ namespace Avalonia.Controls
|
|
|
/// <param name="value">The value to coerce.</param>
|
|
/// <param name="value">The value to coerce.</param>
|
|
|
protected virtual bool OnCoerceIsExpanded(bool value)
|
|
protected virtual bool OnCoerceIsExpanded(bool value)
|
|
|
{
|
|
{
|
|
|
- RoutedEventArgs eventArgs;
|
|
|
|
|
|
|
+ CancelRoutedEventArgs eventArgs;
|
|
|
|
|
|
|
|
if (value)
|
|
if (value)
|
|
|
{
|
|
{
|
|
|
- eventArgs = new RoutedEventArgs(ExpandingEvent, this);
|
|
|
|
|
|
|
+ eventArgs = new CancelRoutedEventArgs(ExpandingEvent, this);
|
|
|
OnExpanding(eventArgs);
|
|
OnExpanding(eventArgs);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- eventArgs = new RoutedEventArgs(CollapsingEvent, this);
|
|
|
|
|
|
|
+ eventArgs = new CancelRoutedEventArgs(CollapsingEvent, this);
|
|
|
OnCollapsing(eventArgs);
|
|
OnCollapsing(eventArgs);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (eventArgs.Handled)
|
|
|
|
|
|
|
+ if (eventArgs.Cancel)
|
|
|
{
|
|
{
|
|
|
- // If the event was externally handled (canceled) we must still notify the value has changed.
|
|
|
|
|
|
|
+ // If the event was externally canceled we must still notify the value has changed.
|
|
|
// This property changed notification will update any external code observing this property that itself may have set the new value.
|
|
// This property changed notification will update any external code observing this property that itself may have set the new value.
|
|
|
// We are essentially reverted any external state change along with ignoring the IsExpanded property set.
|
|
// We are essentially reverted any external state change along with ignoring the IsExpanded property set.
|
|
|
// Remember IsExpanded is usually controlled by a ToggleButton in the control theme and is also used for animations.
|
|
// Remember IsExpanded is usually controlled by a ToggleButton in the control theme and is also used for animations.
|