You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I am having troubles with getting bindings from the model to reflect in the ui using the mvux pattern. I am able to get all the other bindings from the model to work. I am able to get the Tracks Feed to work. I have tried a few different variations of bindings to try and get this problem to fix itself but none of them have worked. The TestTitle is working. And the Console.WriteLine for CurrentAlbum shows that it does exist and is being set, however I cannot get it to reflect in the ui and I am not sure what I am doing wrong. I have also seen this #16277, which I believe had a similar issue but has been resolved, I have tried doing what was mentioned there but it also did not work. So I am lost as to what the issue is on my end. I have simplified the code to make it more readable, but all the important parts should still be there. Thanks for the help.
public sealed partial class TrackPage: Page
{
public TrackPage()
{
this.InitializeComponent();
this.DataContext = (Application.Current as App)?.Host?.Services.GetRequiredService<TrackViewModel>();
}
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
var album = e.Parameter as Album;
await ((TrackViewModel)DataContext).Model.SetCurrentAlbum(album);
}
}
TrackModel
public partial record TrackModel(IArtistService ArtistService, IAudioPlayerService AudioPlayerService, Plex Plex)
{
public Album? Album { get; set; }
public string TestTitle => "Hardcoded Title from Model";
public IState<Album> CurrentAlbum => State<Album>.Empty(this);
public async ValueTask SetCurrentAlbum(Album album)
{
await CurrentAlbum.UpdateAsync(_ => new Album(Rating: album.Rating, Key: album.Key, RatingKey: album.RatingKey, ParentKey: album.ParentKey, ParentRatingKey: album.ParentRatingKey, Guid: album.Guid, ParentGuid: album.ParentGuid, Studio: album.Studio, Type: album.Type, Title: album.Title, Artist: album.Artist, ParentTitle: album.ParentTitle, Summary: album.Summary, Index: album.Index, LastViewedAt: album.LastViewedAt, Year: album.Year, Thumb: album.Thumb, Art: album.Art, ParentThumb: album.ParentThumb, OriginallyAvailableAt: album.OriginallyAvailableAt, AddedAt: album.AddedAt, UpdatedAt: album.UpdatedAt, LoudnessAnalysisVersion: album.LoudnessAnalysisVersion, MusicAnalysisVersion: album.MusicAnalysisVersion));
Console.WriteLine($"Current Album {album.Title}");
var dispatcher = Window.Current.DispatcherQueue;
dispatcher.TryEnqueue(async () =>
{
await CurrentAlbum.UpdateAsync(_ => album);
});
Console.WriteLine($"Current Album {CurrentAlbum.Value().Result.Title}");
}
public async Task<string> GetAlbumTitleAsync()
{
var album = await CurrentAlbum; // Asynchronously get the state value
return album?.Title ?? string.Empty;
}
public IListFeed<Track> Tracks => CurrentAlbum.SelectAsync(async (album, ct) =>
{
var trackList = await ArtistService.GetTrackList(ct, Plex, album.RatingKey);
Album = album;
return trackList;
}).AsListFeed().Selection(SelectedTrack);
public IState<Track> SelectedTrack => State<Track>.Empty(this);
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, I am having troubles with getting bindings from the model to reflect in the ui using the mvux pattern. I am able to get all the other bindings from the model to work. I am able to get the Tracks Feed to work. I have tried a few different variations of bindings to try and get this problem to fix itself but none of them have worked. The TestTitle is working. And the Console.WriteLine for CurrentAlbum shows that it does exist and is being set, however I cannot get it to reflect in the ui and I am not sure what I am doing wrong. I have also seen this #16277, which I believe had a similar issue but has been resolved, I have tried doing what was mentioned there but it also did not work. So I am lost as to what the issue is on my end. I have simplified the code to make it more readable, but all the important parts should still be there. Thanks for the help.
The TrackPage
Code Behind
TrackModel
Beta Was this translation helpful? Give feedback.
All reactions