Skip to content

Instantly share code, notes, and snippets.

@sakapon
Created July 4, 2016 09:46
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 sakapon/ba254fee254555754675e320b91d3706 to your computer and use it in GitHub Desktop.
Save sakapon/ba254fee254555754675e320b91d3706 to your computer and use it in GitHub Desktop.
BindingSample / DynamicBindingWpf / MainWindow
using System;
namespace DynamicBindingWpf
{
public class AppModel
{
public dynamic TextModel { get; } = new TextModel().ToDynamicSyncProxy(300);
}
public class TextModel
{
string _Input;
public string Input
{
get { return _Input; }
set
{
_Input = value;
Output = _Input?.ToUpper();
}
}
public string Output { get; private set; }
}
}
<Window x:Class="DynamicBindingWpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DynamicBindingWpf"
Title="Dynamic Binding" Height="400" Width="600" FontSize="36">
<Window.DataContext>
<local:AppModel/>
</Window.DataContext>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBox Text="{Binding TextModel.Input, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap"/>
<TextBlock Text="{Binding TextModel.Output}" TextWrapping="Wrap" Grid.Row="1"/>
</Grid>
</Window>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment