-
Notifications
You must be signed in to change notification settings - Fork 1
/
AppShell.cs
37 lines (29 loc) · 887 Bytes
/
AppShell.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
using Autofac;
namespace kr.bbon.Xamarin.Forms
{
public class AppShell : ShellBase
{
}
public class AppShell<TViewModel> : AppShell
where TViewModel : ViewModelBase
{
public AppShell()
: base()
{
using (var scope = AppContainer.Instance.Container.BeginLifetimeScope())
{
var viewModelObj = scope.Resolve<TViewModel>();
viewModelObj.AttachAppearingEvent(this);
viewModelObj.AttachDisappearingEvent(this);
viewModelObj.AttachOnLoadEvent(this);
this.viewModel = viewModelObj;
}
if (viewModel != null)
{
BindingContext = viewModel;
}
}
public TViewModel ViewModel { get => viewModel; }
private readonly TViewModel viewModel;
}
}