File tree 4 files changed +124
-0
lines changed
src/Avalonia.Xaml.Interactions.Custom/Core
4 files changed +124
-0
lines changed Original file line number Diff line number Diff line change
1
+ using System . Reactive . Disposables ;
2
+ using Avalonia . Xaml . Interactivity ;
3
+
4
+ namespace Avalonia . Xaml . Interactions . Custom ;
5
+
6
+ /// <summary>
7
+ /// A base class for behaviors using ActualThemeVariantChanged event.
8
+ /// </summary>
9
+ /// <typeparam name="T"></typeparam>
10
+ public abstract class ActualThemeVariantChangedBehavior < T > : DisposingBehavior < T > where T : StyledElement
11
+ {
12
+ private CompositeDisposable ? _disposables ;
13
+
14
+ /// <inheritdoc />
15
+ protected override void OnAttached ( CompositeDisposable disposables )
16
+ {
17
+ _disposables = disposables ;
18
+ }
19
+
20
+ /// <inheritdoc />
21
+ protected override void OnActualThemeVariantChangedEvent ( )
22
+ {
23
+ OnActualThemeVariantChangedEvent ( _disposables ! ) ;
24
+ }
25
+
26
+ /// <summary>
27
+ /// Called when the <see cref="StyledElementBehavior{T}.AssociatedObject"/> ActualThemeVariantChanged event is raised.
28
+ /// </summary>
29
+ /// <param name="disposable">The group of disposable resources that are disposed together</param>
30
+ protected abstract void OnActualThemeVariantChangedEvent ( CompositeDisposable disposable ) ;
31
+ }
Original file line number Diff line number Diff line change
1
+ using System . Reactive . Disposables ;
2
+ using Avalonia . Xaml . Interactivity ;
3
+
4
+ namespace Avalonia . Xaml . Interactions . Custom ;
5
+
6
+ /// <summary>
7
+ /// A base class for behaviors using DataContextChanged event.
8
+ /// </summary>
9
+ /// <typeparam name="T"></typeparam>
10
+ public abstract class DataContextChangedBehavior < T > : DisposingBehavior < T > where T : StyledElement
11
+ {
12
+ private CompositeDisposable ? _disposables ;
13
+
14
+ /// <inheritdoc />
15
+ protected override void OnAttached ( CompositeDisposable disposables )
16
+ {
17
+ _disposables = disposables ;
18
+ }
19
+
20
+ /// <inheritdoc />
21
+ protected override void OnDataContextChangedEvent ( )
22
+ {
23
+ OnDataContextChangedEvent ( _disposables ! ) ;
24
+ }
25
+
26
+ /// <summary>
27
+ /// Called when the <see cref="StyledElementBehavior{T}.AssociatedObject"/> DataContextChanged event is raised.
28
+ /// </summary>
29
+ /// <param name="disposable">The group of disposable resources that are disposed together</param>
30
+ protected abstract void OnDataContextChangedEvent ( CompositeDisposable disposable ) ;
31
+ }
Original file line number Diff line number Diff line change
1
+ using System . Reactive . Disposables ;
2
+ using Avalonia . Xaml . Interactivity ;
3
+
4
+ namespace Avalonia . Xaml . Interactions . Custom ;
5
+
6
+ /// <summary>
7
+ /// A base class for behaviors using Initialized event.
8
+ /// </summary>
9
+ /// <typeparam name="T"></typeparam>
10
+ public abstract class InitializedBehavior < T > : DisposingBehavior < T > where T : StyledElement
11
+ {
12
+ private CompositeDisposable ? _disposables ;
13
+
14
+ /// <inheritdoc />
15
+ protected override void OnAttached ( CompositeDisposable disposables )
16
+ {
17
+ _disposables = disposables ;
18
+ }
19
+
20
+ /// <inheritdoc />
21
+ protected override void OnInitializedEvent ( )
22
+ {
23
+ OnInitializedEvent ( _disposables ! ) ;
24
+ }
25
+
26
+ /// <summary>
27
+ /// Called when the <see cref="StyledElementBehavior{T}.AssociatedObject"/> Initialized event is raised.
28
+ /// </summary>
29
+ /// <param name="disposable">The group of disposable resources that are disposed together</param>
30
+ protected abstract void OnInitializedEvent ( CompositeDisposable disposable ) ;
31
+ }
Original file line number Diff line number Diff line change
1
+ using System . Reactive . Disposables ;
2
+ using Avalonia . Xaml . Interactivity ;
3
+
4
+ namespace Avalonia . Xaml . Interactions . Custom ;
5
+
6
+ /// <summary>
7
+ /// A base class for behaviors using ResourcesChanged event.
8
+ /// </summary>
9
+ /// <typeparam name="T"></typeparam>
10
+ public abstract class ResourcesChangedBehavior < T > : DisposingBehavior < T > where T : StyledElement
11
+ {
12
+ private CompositeDisposable ? _disposables ;
13
+
14
+ /// <inheritdoc />
15
+ protected override void OnAttached ( CompositeDisposable disposables )
16
+ {
17
+ _disposables = disposables ;
18
+ }
19
+
20
+ /// <inheritdoc />
21
+ protected override void OnResourcesChangedEvent ( )
22
+ {
23
+ OnResourcesChangedEvent ( _disposables ! ) ;
24
+ }
25
+
26
+ /// <summary>
27
+ /// Called when the <see cref="StyledElementBehavior{T}.AssociatedObject"/> ResourcesChanged event is raised.
28
+ /// </summary>
29
+ /// <param name="disposable">The group of disposable resources that are disposed together</param>
30
+ protected abstract void OnResourcesChangedEvent ( CompositeDisposable disposable ) ;
31
+ }
You can’t perform that action at this time.
0 commit comments