-
-
Notifications
You must be signed in to change notification settings - Fork 5
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 #29 from wieslawsoltes/CustomReactiveBehaviors
Add new custom reactive event behaviors
- Loading branch information
Showing
4 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
src/Avalonia.Xaml.Interactions.Custom/Core/ActualThemeVariantChangedBehavior.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Reactive.Disposables; | ||
using Avalonia.Xaml.Interactivity; | ||
|
||
namespace Avalonia.Xaml.Interactions.Custom; | ||
|
||
/// <summary> | ||
/// A base class for behaviors using ActualThemeVariantChanged event. | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public abstract class ActualThemeVariantChangedBehavior<T> : DisposingBehavior<T> where T : StyledElement | ||
{ | ||
private CompositeDisposable? _disposables; | ||
|
||
/// <inheritdoc /> | ||
protected override void OnAttached(CompositeDisposable disposables) | ||
{ | ||
_disposables = disposables; | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void OnActualThemeVariantChangedEvent() | ||
{ | ||
OnActualThemeVariantChangedEvent(_disposables!); | ||
} | ||
|
||
/// <summary> | ||
/// Called when the <see cref="StyledElementBehavior{T}.AssociatedObject"/> ActualThemeVariantChanged event is raised. | ||
/// </summary> | ||
/// <param name="disposable">The group of disposable resources that are disposed together</param> | ||
protected abstract void OnActualThemeVariantChangedEvent(CompositeDisposable disposable); | ||
} |
31 changes: 31 additions & 0 deletions
31
src/Avalonia.Xaml.Interactions.Custom/Core/DataContextChangedBehavior.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Reactive.Disposables; | ||
using Avalonia.Xaml.Interactivity; | ||
|
||
namespace Avalonia.Xaml.Interactions.Custom; | ||
|
||
/// <summary> | ||
/// A base class for behaviors using DataContextChanged event. | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public abstract class DataContextChangedBehavior<T> : DisposingBehavior<T> where T : StyledElement | ||
{ | ||
private CompositeDisposable? _disposables; | ||
|
||
/// <inheritdoc /> | ||
protected override void OnAttached(CompositeDisposable disposables) | ||
{ | ||
_disposables = disposables; | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void OnDataContextChangedEvent() | ||
{ | ||
OnDataContextChangedEvent(_disposables!); | ||
} | ||
|
||
/// <summary> | ||
/// Called when the <see cref="StyledElementBehavior{T}.AssociatedObject"/> DataContextChanged event is raised. | ||
/// </summary> | ||
/// <param name="disposable">The group of disposable resources that are disposed together</param> | ||
protected abstract void OnDataContextChangedEvent(CompositeDisposable disposable); | ||
} |
31 changes: 31 additions & 0 deletions
31
src/Avalonia.Xaml.Interactions.Custom/Core/InitializedBehavior.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Reactive.Disposables; | ||
using Avalonia.Xaml.Interactivity; | ||
|
||
namespace Avalonia.Xaml.Interactions.Custom; | ||
|
||
/// <summary> | ||
/// A base class for behaviors using Initialized event. | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public abstract class InitializedBehavior<T> : DisposingBehavior<T> where T : StyledElement | ||
{ | ||
private CompositeDisposable? _disposables; | ||
|
||
/// <inheritdoc /> | ||
protected override void OnAttached(CompositeDisposable disposables) | ||
{ | ||
_disposables = disposables; | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void OnInitializedEvent() | ||
{ | ||
OnInitializedEvent(_disposables!); | ||
} | ||
|
||
/// <summary> | ||
/// Called when the <see cref="StyledElementBehavior{T}.AssociatedObject"/> Initialized event is raised. | ||
/// </summary> | ||
/// <param name="disposable">The group of disposable resources that are disposed together</param> | ||
protected abstract void OnInitializedEvent(CompositeDisposable disposable); | ||
} |
31 changes: 31 additions & 0 deletions
31
src/Avalonia.Xaml.Interactions.Custom/Core/ResourcesChangedBehavior.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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System.Reactive.Disposables; | ||
using Avalonia.Xaml.Interactivity; | ||
|
||
namespace Avalonia.Xaml.Interactions.Custom; | ||
|
||
/// <summary> | ||
/// A base class for behaviors using ResourcesChanged event. | ||
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
public abstract class ResourcesChangedBehavior<T> : DisposingBehavior<T> where T : StyledElement | ||
{ | ||
private CompositeDisposable? _disposables; | ||
|
||
/// <inheritdoc /> | ||
protected override void OnAttached(CompositeDisposable disposables) | ||
{ | ||
_disposables = disposables; | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void OnResourcesChangedEvent() | ||
{ | ||
OnResourcesChangedEvent(_disposables!); | ||
} | ||
|
||
/// <summary> | ||
/// Called when the <see cref="StyledElementBehavior{T}.AssociatedObject"/> ResourcesChanged event is raised. | ||
/// </summary> | ||
/// <param name="disposable">The group of disposable resources that are disposed together</param> | ||
protected abstract void OnResourcesChangedEvent(CompositeDisposable disposable); | ||
} |