-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainPage.xaml.cs
More file actions
52 lines (41 loc) · 1.33 KB
/
MainPage.xaml.cs
File metadata and controls
52 lines (41 loc) · 1.33 KB
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
using System.Diagnostics;
using WS.Campaigns.Campaign;
namespace WS
{
public partial class MainPage : ContentPage
{
public MainPage()
{
BindingContext = App.CampaignViewModel;
InitializeComponent();
OnAddNewCampaignButtonClicked.Clicked += async (s, e) => await Save();
}
/*
* Before the page appears, get and refresh the list of campaigns.
*/
protected override void OnAppearing()
{
base.OnAppearing();
Dispatcher.DispatchAsync(App.CampaignViewModel.RefreshCampaigns);
}
/*
* Do when the selection changes.
*/
public void OnCollectionViewSelectionChanged(object sender, SelectionChangedEventArgs e)
{
App.CampaignViewModel.SelectedCampaign = e.CurrentSelection.FirstOrDefault() as CampaignVM;
if (App.CampaignViewModel.SelectedCampaign != null)
{
Globals.GoToDetails();
}
}
private async Task Save()
{
statusMessage.Text = "";
await App.CampaignRepo.AddNewCampaign(newCampaign.Text);
statusMessage.Text = App.CampaignRepo.StatusMessage;
Debug.WriteLine("saved entry");
Globals.GoToDetails();
}
}
}