Skip to content

Instantly share code, notes, and snippets.

View nuitsjp's full-sized avatar

Atsushi Nakamura nuitsjp

View GitHub Profile
@nuitsjp
nuitsjp / HatPepper.cs
Created August 12, 2016 06:32
コラム01:PrismとDIコンテナ 02.密結合
public class HatPepper
{
public IList<Shop> SearchShops()
{
IGeolocationService geolocationService = new GeolocationService();
var location = geolocationService.GetCurrentLocation();
// 以降、取得した位置情報から周辺の店舗を取得して返却する
}
}
@nuitsjp
nuitsjp / HatPepper.cs
Last active August 12, 2016 06:31
コラム01:PrismとDIコンテナ 01.密結合
public class HatPepper
{
public IList<Shop> SearchShops()
{
GeolocationService geolocationService = new GeolocationService();
var location = geolocationService.GetCurrentLocation();
// 以降、取得した位置情報から周辺の店舗を取得して返却する
}
}
@nuitsjp
nuitsjp / MainPage.xaml
Created August 11, 2016 10:14
Hello, Prism. MainPage.xaml
<?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="HelloPrism.Views.MainPage"
Title="MainPage">
<StackLayout HorizontalOptions="Center" VerticalOptions="Center">
<Label Text="{Binding Title}" />
</StackLayout>
@nuitsjp
nuitsjp / App.cs
Created August 11, 2016 09:45
Hello, Prism. App.cs
public class App : Application
{
public App()
{
MainPage = new ContentPage
{
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children = {
@nuitsjp
nuitsjp / App.xaml.cs
Created August 11, 2016 09:36
Hello, Prism. App.xaml.cs
public partial class App : PrismApplication
{
public App(IPlatformInitializer initializer = null) : base(initializer) { }
protected override void OnInitialized()
{
InitializeComponent();
NavigationService.NavigateAsync("MainPage?title=Hello%20from%20Xamarin.Forms");
}
protected override void RegisterTypes()
{
@nuitsjp
nuitsjp / AppDelegate.cs
Last active August 11, 2016 09:25
Hello, Prism. AppDelegate.cs Normal
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
}
@nuitsjp
nuitsjp / AppDelegate.cs
Last active August 11, 2016 09:26
Hello, Prism. AppDelegate.cs
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App(new iOSInitializer()));
return base.FinishedLaunching(app, options);
}
}
@nuitsjp
nuitsjp / MainWindowViewModel.cs
Created July 9, 2016 12:47
WPFやXamarinのICommandを改めて整理する VM②
private string _name;
public string Name
{
get { return _name; }
set
{
if (OnPropertyChanged(ref _name, value))
ExecuteCommand.RaiseCanExecuteChanged();
}
}
@nuitsjp
nuitsjp / MainWindowViewModel.cs
Created July 9, 2016 06:40
WPFやXamarinのICommandを改めて整理する VM①
public DelegateCommand ExecuteCommand { get; }
public MainWindowViewModel()
{
ExecuteCommand =
new DelegateCommand(
() => Result = "登録されました",
CanExecute);
}
@nuitsjp
nuitsjp / MainWindow.xaml
Created July 9, 2016 06:03
WPFやXamarinのICommandを改めて整理する XAML
<Window x:Class="CommandSample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:CommandSample"
Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
<local:MainWindowViewModel/>
</Window.DataContext>
<StackPanel Orientation="Vertical">
<Label Content="氏名"/>