Ivan Prodanov
Ivan Prodanov

Reputation: 35502

Why Xelement.Parse() throws an exception?

XElement.Parse("<Style TargetType=\"TextBlock\" x:Key=\"LabelStyle\"><Setter Property=\"TextWrapping\" Value=\"Wrap\"/></Style>");

This throws an exception, why?

I want to join an XML document with some styles so it dynamically renders correctly in the app, because the document misses some styles(i.e this one).

Upvotes: 0

Views: 784

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1499860

I would imagine the problem is that you're using a namespace alias of x, but there's no indication of what that namespace alias means - what URI it corresponds to.

If you include

xmlns:x="http://...."

(with the appropriate namespace URI) then I suspect it'll be fine.

Upvotes: 5

Related Questions