-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml.cs
76 lines (66 loc) · 2.84 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Windows;
using System.Windows.Forms;
using ReactiveUI;
namespace Airports
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window, IViewFor<MainVM>
{
public static readonly DependencyProperty ViewModelProperty = DependencyProperty
.Register(nameof(ViewModel), typeof(MainVM), typeof(MainWindow));
public MainWindow()
{
ViewModel = new MainVM();
InitializeComponent();
// Setup the bindings
// Note: We have to use WhenActivated here, since we need to dispose the
// bindings on XAML-based platforms, or else the bindings leak memory.
this.WhenActivated(disposable =>
{
this.WhenAnyValue(x => x.ViewModel.LastTimeTable)
.ObserveOn(RxApp.MainThreadScheduler)
.BindTo(this, x => x.TableViewLast.DataContext)
.DisposeWith(disposable);
this.Bind(this.ViewModel, x => x.Speed, x => x.SpeedComboBox.SelectedItem);
this.WhenAnyValue(x => x.ViewModel.ImmitationServiceVM.Time)
.ObserveOn(RxApp.MainThreadScheduler)
.BindTo(this, x => x.TextBlockTime.Text,
vmToViewConverterOverride: new DateConverter())
.DisposeWith(disposable);
this.WhenAnyValue(x => x.ViewModel.ArrivalRaitingVM)
.ObserveOn(RxApp.MainThreadScheduler)
.BindTo(this, x => x.RaitingViewLeft.DataContext)
.DisposeWith(disposable);
this.WhenAnyValue(x => x.ViewModel.DepartureRaitingVM)
.ObserveOn(RxApp.MainThreadScheduler)
.BindTo(this, x => x.RaitingViewRight.DataContext)
.DisposeWith(disposable);
/*this.WhenAnyValue(x => x.ViewModel.ArrivalCounts)
.ObserveOn(RxApp.MainThreadScheduler)
.BindTo(this, x => x.ColumnSeriesArrival.ItemsSource)
.DisposeWith(disposable);
this.WhenAnyValue(x => x.ViewModel.DepartmentsCounts)
.ObserveOn(RxApp.MainThreadScheduler)
.BindTo(this, x => x.ColumnSeriesDepartment.ItemsSource)
.DisposeWith(disposable);*/
});
}
public MainVM ViewModel
{
get => (MainVM)GetValue(ViewModelProperty);
set => SetValue(ViewModelProperty, value);
}
object IViewFor.ViewModel
{
get => ViewModel;
set => ViewModel = (MainVM)value;
}
}
}