Skip to content

Instantly share code, notes, and snippets.

@timheuer
Created April 10, 2012 15:52
Show Gist options
  • Save timheuer/2352351 to your computer and use it in GitHub Desktop.
Save timheuer/2352351 to your computer and use it in GitHub Desktop.
dynamic type binding Metro
<Page
x:Class="Application141.BlankPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Application141"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{StaticResource ApplicationPageBackgroundBrush}">
<StackPanel>
<TextBlock Text="{Binding FirstName}" />
<TextBlock Text="{Binding LastName}" />
</StackPanel>
</Grid>
</Page>
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace Application141
{
public sealed partial class BlankPage : Page
{
public BlankPage()
{
this.InitializeComponent();
Loaded += BlankPage_Loaded;
}
void BlankPage_Loaded(object sender, RoutedEventArgs e)
{
dynamic foo = new
{
FirstName = "Tim",
LastName = "Heuer"
};
this.DataContext = foo;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment