This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from chris579/master
v1.1.4
- Loading branch information
Showing
33 changed files
with
697 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
@page "/clock" | ||
@using System.Globalization | ||
@inherits MvvmComponentBase<ClockViewModel> | ||
|
||
<h1>Clock</h1> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
@page "/parameters/{name}" | ||
@inherits MvvmComponentBase<ParametersViewModel> | ||
|
||
<h1>Clock</h1> | ||
|
||
<div class="alert alert-primary" role="alert"> | ||
You can also pass down parameters to your view model. If you set a binding context you can | ||
declare your parameters just as you would before but you also declare them in your view model. | ||
They will be passed down to it automatically. | ||
</div> | ||
|
||
<p>My Name is @Bind(x => x.Name).</p> | ||
|
||
<form class="form-inline"> | ||
<div class="form-group mx-sm-3 mb-2"> | ||
<label for="newName" class="sr-only">New name</label> | ||
<input class="form-control" id="newName" @bind="@BindingContext.NewName"/> | ||
</div> | ||
<button type="button" class="btn btn-primary mb-2" @onclick="@BindingContext.NavigateToNewName">Navigate</button> | ||
</form> | ||
|
||
@code { | ||
|
||
[Parameter] | ||
public string Name { get; set; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
samples/BlazorSample/Client/ViewModel/ParametersViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using MvvmBlazor.ViewModel; | ||
|
||
namespace BlazorSample.Client.ViewModel | ||
{ | ||
public class ParametersViewModel : ViewModelBase | ||
{ | ||
private readonly NavigationManager _navigationManager; | ||
|
||
public ParametersViewModel(NavigationManager navigationManager) | ||
{ | ||
_navigationManager = navigationManager; | ||
} | ||
|
||
[Parameter] public string Name { get; set; } | ||
|
||
public string NewName { get; set; } | ||
|
||
public void NavigateToNewName() | ||
{ | ||
if (string.IsNullOrEmpty(NewName)) | ||
return; | ||
|
||
_navigationManager.NavigateTo($"/parameters/{NewName}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
@page "/parameters/{name}" | ||
@inherits MvvmComponentBase<ParametersViewModel> | ||
|
||
<h1>Clock</h1> | ||
|
||
<div class="alert alert-primary" role="alert"> | ||
You can also pass down parameters to your view model. If you set a binding context you can | ||
declare your parameters just as you would before but you also declare them in your view model. | ||
They will be passed down to it automatically. | ||
</div> | ||
|
||
<p>My Name is @Bind(x => x.Name).</p> | ||
|
||
<form class="form-inline"> | ||
<div class="form-group mx-sm-3 mb-2"> | ||
<label for="newName" class="sr-only">New name</label> | ||
<input class="form-control" id="newName" @bind="@BindingContext.NewName" /> | ||
</div> | ||
<button type="button" class="btn btn-primary mb-2" @onclick="@BindingContext.NavigateToNewName">Navigate</button> | ||
</form> | ||
|
||
@code { | ||
|
||
[Parameter] | ||
public string Name { get; set; } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
samples/BlazorServersideSample/ViewModel/ParametersViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using MvvmBlazor.ViewModel; | ||
|
||
namespace BlazorServersideSample.ViewModel | ||
{ | ||
public class ParametersViewModel : ViewModelBase | ||
{ | ||
private readonly NavigationManager _navigationManager; | ||
|
||
public ParametersViewModel(NavigationManager navigationManager) | ||
{ | ||
_navigationManager = navigationManager; | ||
} | ||
|
||
[Parameter] public string Name { get; set; } | ||
|
||
public string NewName { get; set; } | ||
|
||
public void NavigateToNewName() | ||
{ | ||
if (string.IsNullOrEmpty(NewName)) | ||
return; | ||
|
||
_navigationManager.NavigateTo($"/parameters/{NewName}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.