<?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>Notifying the UI when Entity References Change in Lookup Comboboxes</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/05/04/notifying-the-ui-when-entity-references-change-in-lookup-comboboxes.aspx</link><description>Last week I wrote about how to data bind WPF lookup comboboxes to entities returned from the Entity Framework. I described that the key to this type of binding is setting the SelectedItem to the object reference itself on the navigation property instead</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Notifying the UI when Entity References Change in Lookup Comboboxes</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/05/04/notifying-the-ui-when-entity-references-change-in-lookup-comboboxes.aspx#10346496</link><pubDate>Wed, 05 Sep 2012 11:28:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10346496</guid><dc:creator>KurianOfBorg</dc:creator><description>&lt;p&gt;The problem with this is if you simply set a related entity to null then the UI doesn&amp;#39;t update since only the CollectionChangeAction.Remove condition occurs and OnPropertyChanged is never called.&lt;/p&gt;
&lt;p&gt;Is there a smarter version of this event handler that works with only removals?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10346496" width="1" height="1"&gt;</description></item><item><title>re: Notifying the UI when Entity References Change in Lookup Comboboxes</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/05/04/notifying-the-ui-when-entity-references-change-in-lookup-comboboxes.aspx#10267834</link><pubDate>Tue, 14 Feb 2012 19:02:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10267834</guid><dc:creator>Jeff</dc:creator><description>&lt;p&gt;Having to agree with Ray (on both statements)&lt;/p&gt;
&lt;p&gt;Beth, very good articles. &amp;nbsp;Thank you. &amp;nbsp;Rarely do I read articles written for VB, but this had some stuff i needed to learn.&lt;/p&gt;
&lt;p&gt;Since you write well...can you include C# in future articles as well? &amp;nbsp;(Better yet, JUST C#!!)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10267834" width="1" height="1"&gt;</description></item><item><title>re: Notifying the UI when Entity References Change in Lookup Comboboxes</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/05/04/notifying-the-ui-when-entity-references-change-in-lookup-comboboxes.aspx#10032920</link><pubDate>Wed, 30 Jun 2010 16:53:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10032920</guid><dc:creator>Beth Massi</dc:creator><description>&lt;p&gt;Hi Catherine,&lt;/p&gt;
&lt;p&gt;As long as the objects in the collection implement INotifyPropertyChanged then changes to any property on these objects will be reflected in the UI, including the combobox. &lt;/p&gt;
&lt;p&gt;HTH,&lt;/p&gt;
&lt;p&gt;-B&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10032920" width="1" height="1"&gt;</description></item><item><title>re: Notifying the UI when Entity References Change in Lookup Comboboxes</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/05/04/notifying-the-ui-when-entity-references-change-in-lookup-comboboxes.aspx#10032424</link><pubDate>Wed, 30 Jun 2010 00:11:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10032424</guid><dc:creator>Catherine</dc:creator><description>&lt;p&gt;Is there a way to automatically update a Lookup Combo when the underlying data changes? I have a combo wired up to a CustomerCollection as you have written in your note above, where Customer is a Linq to SQL entity and CustomerCollectin derives from ObservableCollection. I also have a DataGrid showing Customers. They are both wired up to the same CustomerCollection via different CollectionViews. When I insert or remove a Customer via the DataGrid CollectionView the combo updates automatically. But I don&amp;#39;t know how to make this happen for changes. I am doing the changes in an independent Customer object because the requirement is that the DataGrid should not reflect the changes until after they have been saved to the database. So the problem is first to get the changes into the DataGrid CollectionView, and in such a way that the combo updates automatically. I tried deleting the corresponding Customer object (the one with the same CutomerID as the independent object where I do the changes and save them to the database) from the view and re-inserting it, and it all works as required EXCEPT of course where that item was selected in the combo at the time, in which case it then displays the wrong Customer name.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10032424" width="1" height="1"&gt;</description></item><item><title>re: Notifying the UI when Entity References Change in Lookup Comboboxes</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/05/04/notifying-the-ui-when-entity-references-change-in-lookup-comboboxes.aspx#9998523</link><pubDate>Mon, 19 Apr 2010 15:32:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9998523</guid><dc:creator>Ray</dc:creator><description>&lt;p&gt;I love you!&lt;/p&gt;
&lt;p&gt;I have to translate in C# code...&lt;/p&gt;
&lt;p&gt; public Order() : base()&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; this.CustomerReference.AssociationChanged +=new CollectionChangeEventHandler(this.Customer_AssociationChanged);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &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;private void Customer_AssociationChanged(object sender, &amp;nbsp;CollectionChangeEventArgs e ) {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (e.Action.Equals(CollectionChangeAction.Remove)) {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;OnPropertyChanging(&amp;quot;Customer&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} else {&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;OnPropertyChanged(&amp;quot;Customer&amp;quot;);&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;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9998523" width="1" height="1"&gt;</description></item><item><title>Building WPF Business Applications using Entity Framework</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/05/04/notifying-the-ui-when-entity-references-change-in-lookup-comboboxes.aspx#9620684</link><pubDate>Sat, 16 May 2009 05:06:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9620684</guid><dc:creator>Visual Studio Data</dc:creator><description>&lt;p&gt;I’ve been writing a lot about building WPF business applications with Entity Framework using Visual Studio&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9620684" width="1" height="1"&gt;</description></item><item><title>re: Notifying the UI when Entity References Change in Lookup Comboboxes</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/05/04/notifying-the-ui-when-entity-references-change-in-lookup-comboboxes.aspx#9607324</link><pubDate>Tue, 12 May 2009 17:45:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9607324</guid><dc:creator>Daniele Armanasco</dc:creator><description>&lt;p&gt;Thank you Beth.&lt;/p&gt;
&lt;p&gt;To be honest my problem is different; I was simplyfing it because AssociationChanged could solve my trouble. In the truth I need to recalculate some temporary field when I add/remove an associated object. I tried these:&lt;/p&gt;
&lt;p&gt;- call my method in the setter of the association (in the designer); it works but every time I edit the db schema the designer erase my code;&lt;/p&gt;
&lt;p&gt;- implements OnIdmyobjectChanged() in the partial class but it isn't raised when I add/remove myobject to/from the association.&lt;/p&gt;
&lt;p&gt;Am I missing something?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9607324" width="1" height="1"&gt;</description></item><item><title>re: Notifying the UI when Entity References Change in Lookup Comboboxes</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/05/04/notifying-the-ui-when-entity-references-change-in-lookup-comboboxes.aspx#9603158</link><pubDate>Mon, 11 May 2009 18:13:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9603158</guid><dc:creator>Beth Massi</dc:creator><description>&lt;p&gt;Hi Daniele,&lt;/p&gt;
&lt;p&gt;In L2S you can use the technique as when working with DataTables (&lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/vbasic/cc788742.aspx"&gt;http://msdn.microsoft.com/en-us/vbasic/cc788742.aspx&lt;/a&gt;), bind to the foreign key values instead of the association. &lt;/p&gt;
&lt;p&gt;&amp;lt;ComboBox IsEditable=&amp;quot;False&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;DisplayMemberPath=&amp;quot;LastName&amp;quot; &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;SelectedValuePath=&amp;quot;CustomerID&amp;quot; &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;SelectedValue=&amp;quot;{Binding Path=CustomerID}&amp;quot; /&amp;gt;&lt;/p&gt;
&lt;p&gt;HTH,&lt;/p&gt;
&lt;p&gt;-B&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9603158" width="1" height="1"&gt;</description></item><item><title>re: Notifying the UI when Entity References Change in Lookup Comboboxes</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/05/04/notifying-the-ui-when-entity-references-change-in-lookup-comboboxes.aspx#9600587</link><pubDate>Sun, 10 May 2009 17:34:45 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9600587</guid><dc:creator>Daniele Armanasco</dc:creator><description>&lt;p&gt;I have the same problem using Linq2Sql; is there anything similar to AssociationChanged in Linq2Sql?&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9600587" width="1" height="1"&gt;</description></item><item><title>re: Notifying the UI when Entity References Change in Lookup Comboboxes</title><link>http://blogs.msdn.com/b/bethmassi/archive/2009/05/04/notifying-the-ui-when-entity-references-change-in-lookup-comboboxes.aspx#9600139</link><pubDate>Sun, 10 May 2009 09:05:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9600139</guid><dc:creator>Daniele Armanasco</dc:creator><description>&lt;p&gt;I have the same problem but I'm using Linq2Sql; is there anything similar to AssociationChanged in Linq2Sql?&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9600139" width="1" height="1"&gt;</description></item></channel></rss>