-
-
Notifications
You must be signed in to change notification settings - Fork 226
Expand file tree
/
Copy pathContactSelectorDialogViewModel.cs
More file actions
55 lines (47 loc) · 1.54 KB
/
ContactSelectorDialogViewModel.cs
File metadata and controls
55 lines (47 loc) · 1.54 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
53
54
55
using System;
using System.Collections.Generic;
using Prism.Dialogs;
using PrismSample.Models;
using PrismSample.Services;
namespace PrismSample.ViewModels
{
public class ContactSelectorDialogViewModel : BaseViewModel, IDialogAware
{
private readonly IContactsService _contactsService;
public ContactSelectorDialogViewModel(IContactsService contactsService)
{
_contactsService = contactsService;
}
// note: acting upon search query is not implemented
private string _query;
public string Query
{
get => _query;
set => SetProperty(ref _query, value);
}
private List<Contact> _contacts;
public List<Contact> Contacts
{
get => _contacts;
set => SetProperty(ref _contacts, value);
}
private Contact _selectedContact;
public Contact SelectedContact
{
get => _selectedContact;
set => SetProperty(ref _selectedContact, value, onChanged:OnContactSelected);
}
private void OnContactSelected()
{
if(SelectedContact != null)
RequestClose(new DialogParameters {{"Contact", SelectedContact}});
}
public async void OnDialogOpened(IDialogParameters parameters)
{
Contacts = await _contactsService.GetContacts();
}
public bool CanCloseDialog() => true;
public void OnDialogClosed() { }
public event Action<IDialogParameters> RequestClose;
}
}