<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>WPF Basic Data Binding FAQ</title><link>http://blogs.msdn.com/wpfsdk/archive/2006/10/19/wpf-basic-data-binding-faq.aspx</link><description>Through talking to people and monitoring both internal and external forums, I have compiled a list of questions people often have when first learning about WPF data binding. If you have any questions, please leave a comment and let me know! What is target</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: WPF Basic Data Binding FAQ</title><link>http://blogs.msdn.com/wpfsdk/archive/2006/10/19/wpf-basic-data-binding-faq.aspx#869134</link><pubDate>Tue, 24 Oct 2006 19:31:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:869134</guid><dc:creator>BobStrogg</dc:creator><description>&lt;p&gt;I've made a WPF demo that uses the Newton Game Dynamics physics engine to roll some things down the screen, all using databinding. &amp;nbsp;You might want to check it out: &lt;a rel="nofollow" target="_new" href="http://chriscavanagh.wordpress.com/2006/10/23/wpf-2d-physics"&gt;http://chriscavanagh.wordpress.com/2006/10/23/wpf-2d-physics&lt;/a&gt; :)&lt;/p&gt;
</description></item><item><title>re: WPF Basic Data Binding FAQ</title><link>http://blogs.msdn.com/wpfsdk/archive/2006/10/19/wpf-basic-data-binding-faq.aspx#876978</link><pubDate>Thu, 26 Oct 2006 21:00:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:876978</guid><dc:creator>wcsdkteam</dc:creator><description>&lt;p&gt;Wow, that's a really cool demo, Chris! Somehow I really enjoy seeing the car rolling off the screen. :) Thanks for sharing! - Tina&lt;/p&gt;
</description></item><item><title>re: WPF Basic Data Binding FAQ</title><link>http://blogs.msdn.com/wpfsdk/archive/2006/10/19/wpf-basic-data-binding-faq.aspx#1211120</link><pubDate>Tue, 05 Dec 2006 16:13:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1211120</guid><dc:creator>SaravanaMV</dc:creator><description>&lt;p&gt;Hi there, I'm trying hard to find out the event that will be raised when data binding. Example, I'm binding to a DataTable in a Dataset, and displaying the result using ListView. All I wanted to do is to construct a custom ContextMenu for each item in the ListView during data binding. The context menu content will vary from item to item (atleast the enabled property will change). At the moment I got the ContextMenu element for the ListView in XAML using ListView.ContextMenu element. Its showing the ContextMenu on each line item as expected, but since its referencing to a single context menu, any property change in MenuItem is reflected on each row.&lt;/p&gt;
&lt;p&gt;Any thoughts?&lt;/p&gt;
&lt;p&gt;Saravana&lt;/p&gt;
</description></item><item><title>re: WPF Basic Data Binding FAQ</title><link>http://blogs.msdn.com/wpfsdk/archive/2006/10/19/wpf-basic-data-binding-faq.aspx#1214290</link><pubDate>Wed, 06 Dec 2006 00:55:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1214290</guid><dc:creator>wcsdkteam</dc:creator><description>&lt;p&gt;Hi Saravana,&lt;/p&gt;
&lt;p&gt;I may be simplifying your problem but would something like the following work in your scenario?&lt;/p&gt;
&lt;p&gt;&amp;lt;ListView.ContextMenu&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;&amp;lt;ContextMenu&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;lt;MenuItem Header=&amp;quot;{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem.Content}&amp;quot;/&amp;gt;&lt;/p&gt;
&lt;p&gt; &amp;nbsp;&amp;lt;/ContextMenu&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;/ListView.ContextMenu&amp;gt;&lt;/p&gt;
&lt;p&gt;If not, perhaps you can send us a simplified version of your code so we can take a look.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Tina&lt;/p&gt;
</description></item><item><title>re: WPF Basic Data Binding FAQ</title><link>http://blogs.msdn.com/wpfsdk/archive/2006/10/19/wpf-basic-data-binding-faq.aspx#4372137</link><pubDate>Mon, 13 Aug 2007 23:58:51 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4372137</guid><dc:creator>Ben.Henderson</dc:creator><description>&lt;p&gt;Tina, thanks so much for this FAQ. You really helped me over the hump in areas areas.&lt;/p&gt;
&lt;p&gt;- Ben &lt;/p&gt;
</description></item><item><title>re: WPF Basic Data Binding FAQ</title><link>http://blogs.msdn.com/wpfsdk/archive/2006/10/19/wpf-basic-data-binding-faq.aspx#9752414</link><pubDate>Mon, 15 Jun 2009 11:37:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9752414</guid><dc:creator>johnds</dc:creator><description>&lt;p&gt;Hi Tina,&lt;/p&gt;
&lt;p&gt;I am struggling with WPF binding, trying to do the simplist thing, but it doesnt seem to work.&lt;/p&gt;
&lt;p&gt;I have a simple WPF application, with a Window XAML and code behind, nothing unusual. In my code behind file, I have a public instance property of the Window class. I simply want to bind that property to the text of a textbox, bound TwoWay.&lt;/p&gt;
&lt;p&gt;It's amazing, i just cant seem to get it to work!&lt;/p&gt;
&lt;p&gt;How on earth do you bind custom properties of the containing class (Be-it an Window, UserControl, whatever), to UI elements which the class contains??????????????&lt;/p&gt;
</description></item><item><title>re: Binding to a property of the containing class</title><link>http://blogs.msdn.com/wpfsdk/archive/2006/10/19/wpf-basic-data-binding-faq.aspx#9762562</link><pubDate>Tue, 16 Jun 2009 18:51:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9762562</guid><dc:creator>Carole Snyder</dc:creator><description>&lt;P&gt;Hi John,&lt;/P&gt;
&lt;P&gt;I created a simple sample that binds a TextBox to a property called AString on a Window and binds a Label to the same property:&lt;/P&gt;
&lt;P&gt;&amp;lt;Window x:Class="ThemeResource.Window1"&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;xmlns="&lt;A href="http://schemas.microsoft.com/winfx/2006/xaml/presentation%22" target=_new rel=nofollow&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;xmlns:x="&lt;A href="http://schemas.microsoft.com/winfx/2006/xaml%22" target=_new rel=nofollow&gt;http://schemas.microsoft.com/winfx/2006/xaml"&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;xmlns:local="clr-namespace:ThemeResource" &amp;nbsp;(Change this value to match the namespace in your project}&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Title="Window1" Height="300" Width="300"&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;lt;StackPanel &amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;lt;Label Content="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:Window1}}, Path=AString}"/&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;lt;TextBox Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:Window1}}, &lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Path=AString, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;lt;/StackPanel&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;lt;/Window&amp;gt;&lt;/P&gt;
&lt;P&gt;When you type into the textbox, AString changes, but the label content doesn't because the label doesn't know that the property changed. &amp;nbsp;To notify Label that the property changes, I implemented INotifyPropertyChanged on my Window1 class:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;public partial class Window1 : Window, INotifyPropertyChanged&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public Window1()&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;InitializeComponent();&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AString = "this is a string";&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;string s;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public string AString&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;get { return s; }&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;set&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;s = value;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;OnPropertyChanged("AString");&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#region INotifyPropertyChanged Members&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public event PropertyChangedEventHandler PropertyChanged;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Create the OnPropertyChanged method to raise the event&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;protected void OnPropertyChanged(string name)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PropertyChangedEventHandler handler = PropertyChanged;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (handler != null)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;handler(this, new PropertyChangedEventArgs(name));&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;#endregion&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;
&lt;P&gt;Hope that helps.&lt;/P&gt;
&lt;P&gt;Carole &lt;/P&gt;</description></item><item><title>re: WPF Basic Data Binding FAQ</title><link>http://blogs.msdn.com/wpfsdk/archive/2006/10/19/wpf-basic-data-binding-faq.aspx#9793967</link><pubDate>Sat, 20 Jun 2009 23:13:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9793967</guid><dc:creator>thrivingtoday</dc:creator><description>&lt;p&gt;Tina,&lt;/p&gt;
&lt;p&gt;Thanks for this article. &amp;nbsp;I have an application that's essentially a master-detail application. &amp;nbsp;My main window contains a TreeView. The details are viewed through several usercontrols. How do I bind the textboxes and listviews from the usercontrols to the SelectedItem of the Treeview?&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;John&lt;/p&gt;
</description></item><item><title>re: WPF Basic Data Binding FAQ</title><link>http://blogs.msdn.com/wpfsdk/archive/2006/10/19/wpf-basic-data-binding-faq.aspx#9797867</link><pubDate>Mon, 22 Jun 2009 18:59:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9797867</guid><dc:creator>Carole Snyder</dc:creator><description>&lt;p&gt;Hi John,&lt;/p&gt;
&lt;p&gt;You can bind the DataContext of your user controls to the selected item in the treeview like this:&lt;/p&gt;
&lt;p&gt;&amp;lt;src:UserControl1 Grid.Row=&amp;quot;5&amp;quot; DataContext=&amp;quot;{Binding ElementName=Master, Path=SelectedItem}&amp;quot;/&amp;gt;&lt;/p&gt;
&lt;p&gt;Then in the use control you can bind to properties of the selected object. &amp;nbsp;For example, if your TreeView is bound to an object that has a property called Description, you can put the following in your user control to display Discription's value:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;&amp;lt;TextBlock Text=&amp;quot;{Binding Path=Description}&amp;quot;/&amp;gt;&lt;/p&gt;
&lt;p&gt;Hope that helps,&lt;/p&gt;
&lt;p&gt;Carole&lt;/p&gt;
</description></item></channel></rss>