Skip to content

Instantly share code, notes, and snippets.

@aadennis
Created November 15, 2017 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aadennis/08940f5a32f4694506dfd31a57a009c1 to your computer and use it in GitHub Desktop.
Save aadennis/08940f5a32f4694506dfd31a57a009c1 to your computer and use it in GitHub Desktop.
Most basic of Prism Binding apps
MahVm.cs
--
using Prism.Mvvm;
namespace SmallPrism.ViewModel {
public class MahVm : BindableBase {
private string _name;
public string Name {
get { return _name; }
set {
if (_name == value) return;
_name = value;
RaisePropertyChanged(nameof(Name));
}
}
public MahVm() {
Name = "TweetyPie";
}
}
}
--
MainPage.xaml.cs
using Windows.UI.Xaml.Controls;
using SmallPrism.ViewModel;
namespace SmallPrism {
public sealed partial class MainPage : Page {
MahVm mahVm = new MahVm();
public MainPage() {
this.InitializeComponent();
}
}
}
--
MainPage.xaml
<Page
x:Class="SmallPrism.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Orientation="Vertical">
<TextBox HorizontalAlignment="Left" Height="40" Margin="52,45,0,0" TextWrapping="Wrap" Text="{x:Bind Path=x.Name, Mode=TwoWay}"
VerticalAlignment="Top" Width="221"/>
<TextBox HorizontalAlignment="Left" Height="40" Margin="52,45,0,0" TextWrapping="Wrap" Text="{x:Bind Path=x.Name, Mode=TwoWay}"
VerticalAlignment="Top" Width="221"/>
</StackPanel>
</Grid>
</Page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment