Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <Window x:Class="WpfApplication4.MainWindow"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:l="clr-namespace:WpfApplication4"
- Title="MainWindow" Height="350" Width="525">
- <Window.Resources>
- <l:MyData x:Key="data" />
- </Window.Resources>
- <Grid DataContext="{StaticResource ResourceKey=data}">
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="*"/>
- <ColumnDefinition Width="5"/>
- <ColumnDefinition Width="*"/>
- </Grid.ColumnDefinitions>
- <TextBox Text="{Binding Path=MyProperty, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top"></TextBox>
- <GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Stretch" Background="#FFFFFF" ResizeBehavior="PreviousAndNext"/>
- <TextBlock Grid.Column="2" Text="{Binding Path=MyProperty}" />
- </Grid>
- </Window>
- using System;
- using System.ComponentModel;
- using System.Windows;
- using System.Windows.Controls;
- namespace WpfApplication4
- {
- /// <summary>
- /// Interaction logic for MainWindow.xaml
- /// </summary>
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- }
- public class MyData : INotifyPropertyChanged
- {
- private double myProperty;
- public double MyProperty { get { return myProperty; } set { myProperty = value; Notify("MyProperty"); } }
- private void Notify(string p)
- {
- if(PropertyChanged != null)
- PropertyChanged(this, new PropertyChangedEventArgs(p));
- }
- public MyData()
- {
- MyProperty = 0;
- }
- public event PropertyChangedEventHandler PropertyChanged;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement