/
anna_grinchenko
/
ReactiveUISample
Обзор
Документация
Войти
/
anna_grinchenko
/
ReactiveUISample
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
ViewModels/ContactDialogViewModel.cs
45 строк
1 KB
GrinchenkoAnna
Добавлен вызов диалогового окна редактирования по двойному клику на контакте (Interaction)
26 июн 2026, 15:35
26 июн 2026, 15:35
e773718
Код
Авторство
О чём код?
using ReactiveUI; using ReactiveUI.SourceGenerators; namespace ReactiveUISample.ViewModels { public partial class ContactDialogViewModel : ReactiveObject { [Reactive] private string _name; [Reactive] private string _email; [Reactive] private bool _isNew; public ReactiveCommand<System.Reactive.Unit, ContactDialogResultDto> SaveCommand { get; } public ReactiveCommand<System.Reactive.Unit, System.Reactive.Unit> CancelCommand { get; } public ContactDialogViewModel() { var canSave = this.WhenAnyValue(x => x.Name, x => x.Email, (name, email) => !string.IsNullOrWhiteSpace(name) && !string.IsNullOrWhiteSpace(email)); SaveCommand = ReactiveCommand.Create( () => new ContactDialogResultDto { Name = Name, Email = Email, IsNew = IsNew }, canSave); CancelCommand = ReactiveCommand.Create(() => { }); } public void LoadFromContact(ContactViewModel contactVM) { Name = contactVM.Name; Email = contactVM.Email; IsNew = contactVM.IsNew; } } public class ContactDialogResultDto { public string Name { get; set; } = string.Empty; public string Email { get; set; } = string.Empty; public bool IsNew { get; set; } } }