Die ContentView -Seite zum Initialisieren von Aufrufen des Konstruktors und der Ladebeobachtung und ContentView hat ein eigenes ViewModel und Itemsource als Beobachtungsvorschriften für iCollectionView in xaml < /p>
Datenlasten in der Beobachtungsschärfe, aber es wird nicht aktualisiert, dass die Benutzeroberfläche die UI zum Anzeigen der Anzeige der angezeigt wird Die Werte < /p>
Zweitens beobachtete Objekte -Elemente hat eine untergeordnete Liste von Mitgliedern, die in CollectionView verschachtelt sind. Leider aktualisiert es auch nicht auch die Benutzeroberfläche, < /p>
, wenn ich es tue, nicht Falsch Bitte helfen Sie mir dabei, da ich zum ersten Mal mit Maui -Anwendung arbeite < /p>
Code: Select all
namespace KPTBMSV2.ViewModels
{
public partial class HomePageViewModel : ObservableObject
{
private readonly AuthenticationService _authenticationService;
private readonly BoardService _boardService;
HttpClient _httpClientFactory;
private readonly BoardsView _boardView;
[ObservableProperty]
private bool isAdministrator;
[ObservableProperty]
private string username;
private int _editUserAccountId;
public HomePageViewModel(AuthenticationService authenticationService, IHttpClientFactory httpClientFactory, BoardsView boardsView, BoardService service )
{
_authenticationService = authenticationService;
_httpClientFactory = httpClientFactory.CreateClient("AppHttpClient");
_boardService = service;
_boardView = boardsView;
}
[RelayCommand]
private async Task Logout()
{
_authenticationService.Logout();
await Shell.Current.GoToAsync($"//{nameof(MainPage)}");
}
public async Task Initialize()
{
await CheckAuthenticationStatus();
}
private async Task CheckAuthenticationStatus()
{
await _authenticationService.FetchUserAccountSession();
if (_authenticationService.UserAccountSession is null)
{
Shell.Current.GoToAsync($"//{nameof(MainPage)}");
}else
{
if (_httpClientFactory.DefaultRequestHeaders.Contains("Authorization"))
_httpClientFactory.DefaultRequestHeaders.Remove("Authorization");
_httpClientFactory.DefaultRequestHeaders.Add("Authorization",$"Bearer {_authenticationService.UserAccountSession.AccessToken}");
isAdministrator = _authenticationService.IsAdmin;
Username = _authenticationService.UserAccountSession.Username;
}
}
[RelayCommand]
private async Task OnBoardNav()
{
ContentPage cp = (HomePage)AppShell.Current.CurrentPage;
RadNavigationView radNavigationView = (RadNavigationView)cp.FindByName("navigationView");
radNavigationView.Content = _boardView;
}
[RelayCommand]
private async Task BoardNavClick()
{
//scheldulerBoardData = await _boardService.GetScheduledBoards();
ContentPage cp = (HomePage)AppShell.Current.CurrentPage;
RadNavigationView radNavigationView = (RadNavigationView)cp.FindByName("navigationView");
radNavigationView.Content = new BoardsView(_boardService);
}
}
}
< / Code>
contentVieven - boardvieven - xaml code < / p>
< /code>
boardViewModel < /p>
namespace KPTBMSV2.ViewModels
{
public partial class BoardViewModel : ObservableObject
{
private readonly BoardService _boardService;
public BoardViewModel(BoardService boardService)
{
_boardService = boardService;
GetBoardEvents();
//
}
[ObservableProperty]
public ObservableCollection scheldulerBoardData;
private async Task GetBoardEvents()
{
ScheldulerBoardData = await _boardService.GetScheduledBoards();
//OnPropertyChanged(nameof(ScheldulerBoardData));
}
[RelayCommand]
private void EventTapped()
{
}
}
}
< /code>
Homepage --- xaml < /p>