Last active
July 3, 2016 14:44
-
-
Save sakapon/9bb1faba9de1a320cc2ecc863f2aa4d5 to your computer and use it in GitHub Desktop.
BindingSample / ExpandoBindingWpf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
xmlns:local="clr-namespace:ExpandoBindingWpf" | |
xmlns:Dynamic="clr-namespace:System.Dynamic;assembly=System.Core" | |
x:Class="ExpandoBindingWpf.MainWindow" | |
Title="Expando Binding" Height="400" Width="600" FontSize="36"> | |
<Window.DataContext> | |
<Dynamic:ExpandoObject/> | |
</Window.DataContext> | |
<Grid> | |
<Grid.RowDefinitions> | |
<RowDefinition/> | |
<RowDefinition/> | |
</Grid.RowDefinitions> | |
<TextBox Text="{Binding Input, UpdateSourceTrigger=PropertyChanged}" TextWrapping="Wrap"/> | |
<TextBlock Text="{Binding Output}" TextWrapping="Wrap" Grid.Row="1"/> | |
</Grid> | |
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.ComponentModel; | |
using System.Windows; | |
namespace ExpandoBindingWpf | |
{ | |
public partial class MainWindow : Window | |
{ | |
public MainWindow() | |
{ | |
InitializeComponent(); | |
dynamic model = DataContext; | |
((INotifyPropertyChanged)model).PropertyChanged += (o, e) => | |
{ | |
if (e.PropertyName == "Input") | |
model.Output = model.Input?.ToUpper(); | |
}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment