-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
FakeViewWithContract.cs
85 lines (69 loc) · 3 KB
/
FakeViewWithContract.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
77
78
79
80
81
82
83
84
85
// Copyright (c) 2023 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.
using System.Windows;
using System.Windows.Controls;
namespace ReactiveUI.Tests.Wpf;
public static class FakeViewWithContract
{
internal const string ContractA = "ContractA";
internal const string ContractB = "ContractB";
public class MyViewModel : ReactiveObject
{
}
/// <summary>
/// Used as the default view with no contracted.
/// </summary>
public class View0 : UserControl, IViewFor<MyViewModel>
{
// Using a DependencyProperty as the backing store for ViewModel. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register("ViewModel", typeof(MyViewModel), typeof(View0), new PropertyMetadata(null));
/// <summary>
/// Gets or sets the ViewModel.
/// </summary>
public MyViewModel? ViewModel
{
get { return (MyViewModel)GetValue(ViewModelProperty); }
set { SetValue(ViewModelProperty, value); }
}
object? IViewFor.ViewModel { get => ViewModel; set => ViewModel = (MyViewModel?)value; }
}
/// <summary>
/// the view with ContractA.
/// </summary>
public class ViewA : UserControl, IViewFor<MyViewModel>
{
// Using a DependencyProperty as the backing store for ViewModel. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register("ViewModel", typeof(MyViewModel), typeof(ViewA), new PropertyMetadata(null));
/// <summary>
/// Gets or sets the ViewModel.
/// </summary>
public MyViewModel? ViewModel
{
get { return (MyViewModel)GetValue(ViewModelProperty); }
set { SetValue(ViewModelProperty, value); }
}
object? IViewFor.ViewModel { get => ViewModel; set => ViewModel = (MyViewModel?)value; }
}
/// <summary>
/// the view as ContractB.
/// </summary>
public class ViewB : UserControl, IViewFor<MyViewModel>
{
// Using a DependencyProperty as the backing store for ViewModel. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register("ViewModel", typeof(MyViewModel), typeof(ViewB), new PropertyMetadata(null));
/// <summary>
/// Gets or sets the ViewModel.
/// </summary>
public MyViewModel? ViewModel
{
get { return (MyViewModel)GetValue(ViewModelProperty); }
set { SetValue(ViewModelProperty, value); }
}
object? IViewFor.ViewModel { get => ViewModel; set => ViewModel = (MyViewModel?)value; }
}
}