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
<?xml version="1.0" encoding="utf-8" ?> | |
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms" | |
prism:ViewModelLocator.AutowireViewModel="True" | |
x:Class="NavigationService.Views.MainPage" | |
Title="MainPage"> | |
<StackLayout HorizontalOptions="Center" VerticalOptions="Center"> | |
<Label Text="{Binding Title}" /> | |
<Button Text="Navigate Second Page." Command="{Binding NavigateSecondCommand}"/> |
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
private readonly INavigationService _navigationService; | |
public ICommand NavigateSecondCommand { get; } | |
public MainPageViewModel(INavigationService navigationService) | |
{ | |
_navigationService = navigationService; | |
NavigateSecondCommand = new DelegateCommand(() => | |
{ | |
_navigationService.NavigateAsync("SecondPage"); | |
}); | |
} |
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
private readonly INavigationService _navigationService; | |
public MainPageViewModel(INavigationService navigationService) | |
{ | |
_navigationService = navigationService; | |
} |
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
protected override void RegisterTypes() | |
{ | |
Container.RegisterTypeForNavigation<MainPage>(); | |
Container.RegisterTypeForNavigation<SecondPage>(); | |
} |
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
public class SecondPageViewModel : BindableBase | |
{ | |
public SecondPageViewModel() | |
{ | |
} | |
} |
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
<?xml version="1.0" encoding="utf-8" ?> | |
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | |
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | |
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms" | |
prism:ViewModelLocator.AutowireViewModel="True" | |
x:Class="NavigationService.Views.SecondPage" | |
Title="SecondPage"> | |
<StackLayout Orientation="Vertical" HorizontalOptions="Center" VerticalOptions="Center"> | |
<Label Text="Second Page."/> | |
</StackLayout> |
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
protected override void ConfigureViewModelLocator() | |
{ | |
base.ConfigureViewModelLocator(); | |
ViewModelLocationProvider.Register<MainPage>(() => new MainPageViewModel()); | |
} |
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
protected override void ConfigureViewModelLocator() | |
{ | |
base.ConfigureViewModelLocator(); | |
ViewModelLocationProvider.Register<MainPage, HogeViewModel>(); | |
} |
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
protected override void ConfigureViewModelLocator() | |
{ | |
base.ConfigureViewModelLocator(); // <- 必須!DIされなくなります。 | |
ViewModelLocationProvider.SetDefaultViewTypeToViewModelTypeResolver( | |
viewType => | |
{ | |
var viewName = viewType.FullName; | |
viewName = viewName.Replace(".Views.", ".ViewModels."); | |
string viewModelName; | |
if (viewName.EndsWith("Page")) |
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
public class HatPepper | |
{ | |
private readonly IGeolocationService _geolocationService; | |
public HatPepper(IGeolocationService geolocationService) | |
{ | |
_geolocationService = geolocationService; | |
} | |
public IList<Shop> SearchShops() | |
{ |