Skip to content

Instantly share code, notes, and snippets.

@Majiir
Created November 1, 2015 21:17
Show Gist options
  • Save Majiir/a10831f084c8f666ca8e to your computer and use it in GitHub Desktop.
Save Majiir/a10831f084c8f666ca8e to your computer and use it in GitHub Desktop.
WPF databinding demo
<Window x:Class="WpfDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfDemo"
Title="MainWindow" Height="350" Width="525">
<Window.DataContext>
<local:MyViewModel></local:MyViewModel>
</Window.DataContext>
<Grid>
<Label Content="{Binding Path=MyText}" HorizontalAlignment="Left" VerticalAlignment="Top"/>
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WpfDemo
{
class MyViewModel
{
public string MyText
{
get { return "This value came through a data binding"; }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment