-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MVVM Support for MainLayout.razer #2
Comments
MainLayout.Razor If not I have here a break in the MVVM Logic |
@HubertBieder Not sure what you are asking. Please supply more information. |
I Rebuild my Blazor App and want to use your concept of MVVM with the community Toolkit.
Because I like your concept.
For Normal pages all worked well.
@page "/fetchdata"
@inherits MvvmComponentBase<FetchDataViewModel>
public partial class FetchDataViewModel : ViewModelBase
But the MainLayout.razer is derived from
@inherits LayoutComponentBase
How can I use the MVVM Concept for this MainPage?
How doés the ModelView Class is derived ? And who it ist he notation in the razor file?
Von: Graeme ***@***.***>
Gesendet: Sonntag, 8. Oktober 2023 23:27
An: gragra33/Blazing.Mvvm ***@***.***>
Cc: Hubert Bieder ***@***.***>; Mention ***@***.***>
Betreff: Re: [gragra33/Blazing.Mvvm] MVVM Support for MainLayout.razer (Issue #2)
@HubertBieder<https://github.com/HubertBieder> Not sure what you are asking. Please supply more information.
—
Reply to this email directly, view it on GitHub<#2 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AH2QDKP6EI2HXPBLSAYM5V3X6MLARAVCNFSM6AAAAAA5X4UGO6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJSGE3DMMJWGQ>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
@HubertBieder For that, I will need to add a new public abstract class MvvmLayoutComponentBase<TViewModel>
: LayoutComponentBase, IView<TViewModel> where TViewModel : IViewModelBase
{
[Inject]
protected TViewModel? ViewModel { get; set; }
protected override void OnInitialized()
{
// Cause changes to the ViewModel to make Blazor re-render
ViewModel!.PropertyChanged += (_, _) => InvokeAsync(StateHasChanged);
base.OnInitialized();
}
protected override Task OnInitializedAsync()
=> ViewModel!.OnInitializedAsync();
} I need to run some tests, then I'll push an update. |
Great!
I will use it i if it is released.
Von: Graeme ***@***.***>
Gesendet: Sonntag, 8. Oktober 2023 23:44
An: gragra33/Blazing.Mvvm ***@***.***>
Cc: Hubert Bieder ***@***.***>; Mention ***@***.***>
Betreff: Re: [gragra33/Blazing.Mvvm] MVVM Support for MainLayout.razer (Issue #2)
@HubertBieder<https://github.com/HubertBieder> For that, I will need to add a new LayoutComponentBase class. Something like:
public abstract class MvvmLayoutComponentBase<TViewModel>
: LayoutComponentBase, IView<TViewModel> where TViewModel : IViewModelBase
{
[Inject]
protected TViewModel? ViewModel { get; set; }
protected override void OnInitialized()
{
// Cause changes to the ViewModel to make Blazor re-render
ViewModel!.PropertyChanged += (_, _) => InvokeAsync(StateHasChanged);
base.OnInitialized();
}
protected override Task OnInitializedAsync()
=> ViewModel!.OnInitializedAsync();
}
I need to run some tests, then I'll push an update.
—
Reply to this email directly, view it on GitHub<#2 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AH2QDKICRPTSR6QRMVER6D3X6MNBNAVCNFSM6AAAAAA5X4UGO6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJSGE3DSNJUGQ>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
@HubertBieder v1.1.0 was just pushed to Nuget. Give it a few minutes to be processed. I've also added a demo to the sample project. It's a simple Navigation count. Click on the page links on the left and the count will increment. |
Can I get a MVVM Support for this Razor File ?
If not I have here a break ikn dthe MVVM Logic
The text was updated successfully, but these errors were encountered: