38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using System.Diagnostics;
|
|
using CORP_MAUI.ViewModels;
|
|
|
|
namespace CORP_MAUI.Pages;
|
|
|
|
public partial class ProfilePage : ContentPage
|
|
{
|
|
private readonly ProfileViewModel _viewModel;
|
|
|
|
public ProfilePage()
|
|
{
|
|
InitializeComponent();
|
|
_viewModel = new ProfileViewModel();
|
|
_viewModel.PropertyChanged += OnViewModelPropertyChanged;
|
|
BindingContext = _viewModel;
|
|
}
|
|
|
|
private void OnViewModelPropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
|
{
|
|
if (e.PropertyName == nameof(ProfileViewModel.DisplayImageSource))
|
|
{
|
|
MainThread.BeginInvokeOnMainThread(() =>
|
|
{
|
|
Trace.WriteLine($"[ProfilePage] >>> Обновление аватара через PropertyChanged");
|
|
ProfileAvatarImage.Source = _viewModel.DisplayImageSource;
|
|
});
|
|
}
|
|
}
|
|
|
|
protected override void OnAppearing()
|
|
{
|
|
base.OnAppearing();
|
|
// Load profile every time page appears to keep it fresh
|
|
_viewModel.LoadProfileCommand.Execute(null);
|
|
}
|
|
}
|
|
|