Skip to content

Commit 868840d

Browse files
committed
Add repro
1 parent 772f11b commit 868840d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

samples/BehaviorsTestApplication/ViewModels/MainWindowViewModel.cs

+9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public partial class MainWindowViewModel : ViewModelBase
2121

2222
public IObservable<int> Values { get; }
2323

24+
public ICommand InitializeCommand { get; set; }
25+
2426
public ICommand MoveLeftCommand { get; set; }
2527

2628
public ICommand MoveRightCommand { get; set; }
@@ -31,6 +33,8 @@ public MainWindowViewModel()
3133
{
3234
Count = 0;
3335
Position = 100.0;
36+
InitializeCommand = ReactiveCommand.Create(Initialize);
37+
MoveLeftCommand = ReactiveCommand.Create(() => Position -= 5.0);
3438
MoveLeftCommand = ReactiveCommand.Create(() => Position -= 5.0);
3539
MoveRightCommand = ReactiveCommand.Create(() => Position += 5.0);
3640
ResetMoveCommand = ReactiveCommand.Create(() => Position = 100.0);
@@ -89,6 +93,11 @@ public MainWindowViewModel()
8993
Values = Observable.Interval(TimeSpan.FromSeconds(1)).Select(_ => _value++);
9094
}
9195

96+
private void Initialize()
97+
{
98+
Console.WriteLine("InitializeCommand");
99+
}
100+
92101
public void IncrementCount() => Count++;
93102

94103
public void DecrementCount(object? sender, object parameter) => Count--;
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
<Window x:Class="BehaviorsTestApplication.Views.MainWindow"
22
xmlns="https://github.com/avaloniaui"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:vm="using:BehaviorsTestApplication.ViewModels"
45
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>
614
<views:MainView />
715
</Window>

0 commit comments

Comments
 (0)