File tree 2 files changed +18
-1
lines changed
samples/BehaviorsTestApplication
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ public partial class MainWindowViewModel : ViewModelBase
21
21
22
22
public IObservable < int > Values { get ; }
23
23
24
+ public ICommand InitializeCommand { get ; set ; }
25
+
24
26
public ICommand MoveLeftCommand { get ; set ; }
25
27
26
28
public ICommand MoveRightCommand { get ; set ; }
@@ -31,6 +33,8 @@ public MainWindowViewModel()
31
33
{
32
34
Count = 0 ;
33
35
Position = 100.0 ;
36
+ InitializeCommand = ReactiveCommand . Create ( Initialize ) ;
37
+ MoveLeftCommand = ReactiveCommand . Create ( ( ) => Position -= 5.0 ) ;
34
38
MoveLeftCommand = ReactiveCommand . Create ( ( ) => Position -= 5.0 ) ;
35
39
MoveRightCommand = ReactiveCommand . Create ( ( ) => Position += 5.0 ) ;
36
40
ResetMoveCommand = ReactiveCommand . Create ( ( ) => Position = 100.0 ) ;
@@ -89,6 +93,11 @@ public MainWindowViewModel()
89
93
Values = Observable . Interval ( TimeSpan . FromSeconds ( 1 ) ) . Select ( _ => _value ++ ) ;
90
94
}
91
95
96
+ private void Initialize ( )
97
+ {
98
+ Console . WriteLine ( "InitializeCommand" ) ;
99
+ }
100
+
92
101
public void IncrementCount ( ) => Count ++ ;
93
102
94
103
public void DecrementCount ( object ? sender , object parameter ) => Count -- ;
Original file line number Diff line number Diff line change 1
1
<Window x : Class =" BehaviorsTestApplication.Views.MainWindow"
2
2
xmlns =" https://github.com/avaloniaui"
3
3
xmlns : x =" http://schemas.microsoft.com/winfx/2006/xaml"
4
+ xmlns : vm =" using:BehaviorsTestApplication.ViewModels"
4
5
xmlns : views =" using:BehaviorsTestApplication.Views"
5
- Title =" XamlBehaviors Test Application" Width =" 1000" Height =" 700" >
6
+ Title =" XamlBehaviors Test Application" Width =" 1000" Height =" 700"
7
+ x : DataType =" vm:MainWindowViewModel"
8
+ x : CompileBindings =" False" >
9
+ <Interaction .Behaviors>
10
+ <EventTriggerBehavior EventName =" Opened" >
11
+ <InvokeCommandAction Command =" {Binding InitializeCommand, Mode=OneTime}" />
12
+ </EventTriggerBehavior >
13
+ </Interaction .Behaviors>
6
14
<views : MainView />
7
15
</Window >
You can’t perform that action at this time.
0 commit comments