Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>At first you need you class to implement <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.aspx" rel="noreferrer">INotifyPropertyChanged</a> or a property to be <a href="http://msdn.microsoft.com/en-us/library/system.windows.dependencyproperty.aspx" rel="noreferrer">DependencyProperty</a> for changing property value on textbox text change,</p> <pre><code>namespace WpfApplication1 { public partial class MainWindow : Window, INotifyPropertyChanged { private string _test public string test { get { return _test; } set { _test = value; OnPropertyChanged("test"); } } public MainWindow() { test = "this is a test"; InitializeComponent(); } public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(String info) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(info)); } } } } </code></pre> <p>Than you can bind to that property by giving name to that window, and using ElementName property like this.</p> <pre><code>&lt;Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" Name="myWindow"&gt; &lt;Window.Resources&gt; &lt;ObjectDataProvider x:Key="test"&gt;&lt;/ObjectDataProvider&gt; &lt;/Window.Resources&gt; &lt;Grid&gt; &lt;TextBlock Height="23" HorizontalAlignment="Left" Margin="108,58,0,0" Name="textBlock1" VerticalAlignment="Top" Text="{Binding ElementName=myWindow, Path=test}" /&gt; &lt;/Grid&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload