<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: How can I bind WPF elements to XLinq?</title>
	<atom:link href="http://bea.stollnitz.com/blog/?feed=rss2&#038;p=50" rel="self" type="application/rss+xml" />
	<link>http://bea.stollnitz.com/blog/?p=50</link>
	<description>on Silverlight and WPF</description>
	<lastBuildDate>Thu, 22 Jul 2010 20:56:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Stefan</title>
		<link>http://bea.stollnitz.com/blog/?p=50&#038;cpage=1#comment-213549</link>
		<dc:creator>Stefan</dc:creator>
		<pubDate>Thu, 22 Jul 2010 20:56:04 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=50#comment-213549</guid>
		<description>Just wanted to share.
I have xml data type column in SQL Server database.
I use SqlMetal to generate the dbml. It maps the xml column to XElement.
I bind two-way directly to that XElement in the described above way. No need for XDocument.
Then save the changes back to SQL.
Almost no coding. Except for the Linq to SQL in the DAL. Well and template selector to pick the DataTemplate based on the root Element.Name.LocalName.
Very nice.</description>
		<content:encoded><![CDATA[<p>Just wanted to share.<br />
I have xml data type column in SQL Server database.<br />
I use SqlMetal to generate the dbml. It maps the xml column to XElement.<br />
I bind two-way directly to that XElement in the described above way. No need for XDocument.<br />
Then save the changes back to SQL.<br />
Almost no coding. Except for the Linq to SQL in the DAL. Well and template selector to pick the DataTemplate based on the root Element.Name.LocalName.<br />
Very nice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=50&#038;cpage=1#comment-170159</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Fri, 20 Nov 2009 04:05:55 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=50#comment-170159</guid>
		<description>Hi Dave,

Since XElement&#039;s &quot;Attributes()&quot; method was not one of the chosen ones to be exposed as a property using type descriptor, there is no way to do what you want in XAML. The only way is to call the Attributes() method in code.

Bea</description>
		<content:encoded><![CDATA[<p>Hi Dave,</p>
<p>Since XElement&#8217;s &#8220;Attributes()&#8221; method was not one of the chosen ones to be exposed as a property using type descriptor, there is no way to do what you want in XAML. The only way is to call the Attributes() method in code.</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=50&#038;cpage=1#comment-169962</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Wed, 18 Nov 2009 18:01:46 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=50#comment-169962</guid>
		<description>Hi David,

XElements are really just objects, and Silverlight supports binding to objects. WPF supports the special syntax explained here so that you can specify what you want to bind to using XAML only. Silverlight doesn&#039;t support that syntax, but you can bind directly to the XElement and use a Converter to find the values you want. 

For example, if you have the following XElement:

XElement xElement1 = new XElement(&quot;Root&quot;, new XElement(&quot;Child&quot;, 1));

You could write a Converter like the one below to get to the child&#039;s value:

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
XElement xValue = (XElement)value;
return xValue.Element(&quot;Child&quot;).Value;
}

&lt;TextBlock Text=&quot;{Binding Converter={StaticResource XElementConverter}}&quot; x:Name=&quot;tb1&quot; /&gt;

Let me know if this works for your scenario.

Bea</description>
		<content:encoded><![CDATA[<p>Hi David,</p>
<p>XElements are really just objects, and Silverlight supports binding to objects. WPF supports the special syntax explained here so that you can specify what you want to bind to using XAML only. Silverlight doesn&#8217;t support that syntax, but you can bind directly to the XElement and use a Converter to find the values you want. </p>
<p>For example, if you have the following XElement:</p>
<p>XElement xElement1 = new XElement(&#8220;Root&#8221;, new XElement(&#8220;Child&#8221;, 1));</p>
<p>You could write a Converter like the one below to get to the child&#8217;s value:</p>
<p>public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)<br />
{<br />
XElement xValue = (XElement)value;<br />
return xValue.Element(&#8220;Child&#8221;).Value;<br />
}</p>
<p>&lt;TextBlock Text=&#8221;{Binding Converter={StaticResource XElementConverter}}&#8221; x:Name=&#8221;tb1&#8243; /&gt;</p>
<p>Let me know if this works for your scenario.</p>
<p>Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Bethune</title>
		<link>http://bea.stollnitz.com/blog/?p=50&#038;cpage=1#comment-168785</link>
		<dc:creator>David Bethune</dc:creator>
		<pubDate>Thu, 05 Nov 2009 13:54:19 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=50#comment-168785</guid>
		<description>Must have missed something &#039;cause that &quot;workaround&quot; post doesn&#039;t seem to talk about this at all. Has anyone been able to bind to an Xelement in Silverlight using any workaround?

Thanks!</description>
		<content:encoded><![CDATA[<p>Must have missed something &#8217;cause that &#8220;workaround&#8221; post doesn&#8217;t seem to talk about this at all. Has anyone been able to bind to an Xelement in Silverlight using any workaround?</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=50&#038;cpage=1#comment-168367</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Sat, 31 Oct 2009 00:05:17 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=50#comment-168367</guid>
		<description>That is correct.</description>
		<content:encoded><![CDATA[<p>That is correct.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Dudley</title>
		<link>http://bea.stollnitz.com/blog/?p=50&#038;cpage=1#comment-168144</link>
		<dc:creator>Michael Dudley</dc:creator>
		<pubDate>Wed, 28 Oct 2009 18:57:12 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=50#comment-168144</guid>
		<description>Just to emphasize: XLINQ can&#039;t be used with XmlDataProvider, it must be used with an XDocument.</description>
		<content:encoded><![CDATA[<p>Just to emphasize: XLINQ can&#8217;t be used with XmlDataProvider, it must be used with an XDocument.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://bea.stollnitz.com/blog/?p=50&#038;cpage=1#comment-167154</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Tue, 20 Oct 2009 17:32:44 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=50#comment-167154</guid>
		<description>Thanks for the article.  This is a big help for working with dynamic properties.  One question, is there any way to bind to the Attributes collection of an XElement?  I have a DataTemplate that is bound to an XDocument&#039;s Elements, and I&#039;m able to bind contols in that data template to the XElement&#039;s name, and the Elements below that XElement.  However, I&#039;d like to display an ItemsControl in my data template which is bound to the Attributes for the XElement in context.  Something like this:



This fails with this error:

BindingExpression path error: &#039;Attributes&#039; property not found on &#039;object&#039; &#039;&#039;XElement&#039;

Is there any way to bind to the entire collection of Attributes since I won&#039;t always know them by name?</description>
		<content:encoded><![CDATA[<p>Thanks for the article.  This is a big help for working with dynamic properties.  One question, is there any way to bind to the Attributes collection of an XElement?  I have a DataTemplate that is bound to an XDocument&#8217;s Elements, and I&#8217;m able to bind contols in that data template to the XElement&#8217;s name, and the Elements below that XElement.  However, I&#8217;d like to display an ItemsControl in my data template which is bound to the Attributes for the XElement in context.  Something like this:</p>
<p>This fails with this error:</p>
<p>BindingExpression path error: &#8216;Attributes&#8217; property not found on &#8216;object&#8217; &#8221;XElement&#8217;</p>
<p>Is there any way to bind to the entire collection of Attributes since I won&#8217;t always know them by name?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bea</title>
		<link>http://bea.stollnitz.com/blog/?p=50&#038;cpage=1#comment-166485</link>
		<dc:creator>Bea</dc:creator>
		<pubDate>Mon, 12 Oct 2009 02:03:44 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=50#comment-166485</guid>
		<description>Hi Andrew,

This post is only for WPF - Silverlight doesn&#039;t yet support this feature.
There are some workarounds though. Here&#039;s an example: &lt;a href=&quot;http://forums.silverlight.net/forums/p/121149/278015.aspx#278015&quot; rel=&quot;nofollow&quot;&gt;http://forums.silverlight.net/forums/p/121149/278015.aspx#278015&lt;/a&gt;.

Thanks,
Bea</description>
		<content:encoded><![CDATA[<p>Hi Andrew,</p>
<p>This post is only for WPF &#8211; Silverlight doesn&#8217;t yet support this feature.<br />
There are some workarounds though. Here&#8217;s an example: <a href="http://forums.silverlight.net/forums/p/121149/278015.aspx#278015" rel="nofollow">http://forums.silverlight.net/forums/p/121149/278015.aspx#278015</a>.</p>
<p>Thanks,<br />
Bea</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bigsby</title>
		<link>http://bea.stollnitz.com/blog/?p=50&#038;cpage=1#comment-166001</link>
		<dc:creator>Bigsby</dc:creator>
		<pubDate>Tue, 06 Oct 2009 02:11:50 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=50#comment-166001</guid>
		<description>Lovely article, Bea.
That&#039;s a keeper.</description>
		<content:encoded><![CDATA[<p>Lovely article, Bea.<br />
That&#8217;s a keeper.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew Hilton</title>
		<link>http://bea.stollnitz.com/blog/?p=50&#038;cpage=1#comment-159837</link>
		<dc:creator>Andrew Hilton</dc:creator>
		<pubDate>Fri, 14 Aug 2009 06:52:30 +0000</pubDate>
		<guid isPermaLink="false">http://bea.stollnitz.com/blog/?p=50#comment-159837</guid>
		<description>The XAML syntax doesn&#039;t work in Silverlight 2/3.  Have not yet seen this documented.</description>
		<content:encoded><![CDATA[<p>The XAML syntax doesn&#8217;t work in Silverlight 2/3.  Have not yet seen this documented.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
