<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Dasher's Corner &#187; DataBinding</title>
	<atom:link href="http://dasher.wordpress.com/tag/databinding/feed/" rel="self" type="application/rss+xml" />
	<link>http://dasher.wordpress.com</link>
	<description>Natural Language &#38; Machine Translation</description>
	<lastBuildDate>Sat, 20 Jun 2009 13:08:28 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='dasher.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/333fa50f89d3d9a1b2eb9aeb6cc7b342?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Dasher's Corner &#187; DataBinding</title>
		<link>http://dasher.wordpress.com</link>
	</image>
			<item>
		<title>DataBinding ObservableCollection with WPF</title>
		<link>http://dasher.wordpress.com/2007/11/24/databinding-observablecollection-with-wpf/</link>
		<comments>http://dasher.wordpress.com/2007/11/24/databinding-observablecollection-with-wpf/#comments</comments>
		<pubDate>Sat, 24 Nov 2007 13:51:39 +0000</pubDate>
		<dc:creator>Dasher</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[DataBinding]]></category>
		<category><![CDATA[ObservableCollection]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dasher.wordpress.com/2007/11/24/databinding-observablecollection-with-wpf/</guid>
		<description><![CDATA[Watch out for the code you place in your sub New() of the ObservableCollection &#8211; it can cause the WPF designer problems as the designer will attempt to execute the constructor during design time.  If you&#8217;re trying to populate the collection from a file based database then the connection string, in some situations, VS 2008 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasher.wordpress.com&blog=86394&post=78&subd=dasher&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Watch out for the code you place in your sub New() of the ObservableCollection &#8211; it can cause the WPF designer problems as the designer will attempt to execute the constructor during design time.  If you&#8217;re trying to populate the collection from a file based database then the connection string, in some situations, VS 2008 will look in the wrong place for the database.  It appears that using the |Data Directory| prefix for the database causes VS 2008 (RTM) to look in the working directory of VS &#8211; rather than the project directory.</p>
<p>Symptoms of this kind of problem are VS reporting:</p>
<p><em>&#8220;Could not create an instance of type &#8216;abc&#8217;. &#8230;Window1.xaml 8 3&#8243;</em> and your XAML reference will be squiggily underlined.<br />
A solution to this problem is wraping the constructor of the object implementing the ObservableCollection in a try/catch and swallowing the error (suggested only during the development cycle) or by detecting if you&#8217;re in designtime.</p>
<p>A simple way to detect if you&#8217;re in designtime with WPF is:<br />
<code><br />
If DesignerProperties.GetIsInDesignMode(Application.Current.MainWindow) Then<br />
  Add(New contact("DesignTime", "Detected"))<br />
Else<br />
  Try<br />
    oContactsTA.Fill(oContacts)<br />
    For Each thisRow In oContacts<br />
      Add(New contact(thisRow))<br />
    Next<br />
  Catch ex As Exception<br />
    Add(New contact("DesignTime", "NotDetected"))<br />
  End Try<br />
End If<br />
</code></p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/dasher.wordpress.com/78/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/dasher.wordpress.com/78/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dasher.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dasher.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dasher.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dasher.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dasher.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dasher.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dasher.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dasher.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dasher.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dasher.wordpress.com/78/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dasher.wordpress.com&blog=86394&post=78&subd=dasher&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://dasher.wordpress.com/2007/11/24/databinding-observablecollection-with-wpf/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/be5e0c2700dfad20c5981478273d4853?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dasher</media:title>
		</media:content>
	</item>
	</channel>
</rss>