开发者

How do you bind to Xml in SilverLight/Windows Phone?

开发者 https://www.devze.com 2023-01-21 09:35 出处:网络
I am trying to use Linq to Xml and Xaml data binding in a Windows Phone app with no luck, following this example.

I am trying to use Linq to Xml and Xaml data binding in a Windows Phone app with no luck, following this example.

I've got some Xaml that looks like this:

    <Image 
           Source="{Binding Path=Element[image].Value, Converter={StaticResource UriBitmapConverter}}" 
           Grid.Column="2" MaxWidth="75" HorizontalAlignment="Right" VerticalAlignment="Top"/>

T开发者_运维问答he DataContext is an XDocument <image>someuri</image>. However this doesn't make it past the parsing stage as I get:

Additional information: Invalid attribute value
{Binding Path=Element[image].Value, Converter={StaticResource UriBitmapConverter}} for property 

Is this sort of binding not possible in Silverlight or am I just missing something?


Create your own object that wraps your XML document with the required properties needed by your page and use that for databinding.

Binding isn't smart enough to work with collections in the way you were trying.

0

精彩评论

暂无评论...
验证码 换一张
取 消