You have to define a parameterless constructor in your TextBox_Element
.
XamlReader.Load by default will always look for an empty constructor while if it has a required parameters you'll have to add more work.
According to Max Galkin
It's a "feature" of the XAML language, it is declarative and doesn't know anything about constructors. People use ObjectDataProvider in XAML to "translate" and wrap instances of classes that do not have a parameterless constructor (it's [also useful for data binding][2]).
In your case it'll be approximately like this:
<ObjectDataProvider ObjectType="TextBox_Element">
<ObjectDataProvider.ConstructorParameters>
<x:Double>400</x:Double>
<x:Double>200</x:Double>
</ObjectDataProvider.ConstructorParameters>
</ObjectDataProvider>
var textBoxElem = (TextBox_Element) ((ObjectDataProvider)XamlReader.Parse(xamlStr)).Data;
Assuming your TextBox_Element
constructor looks like this
public class TextBox_Element
{
public TextBox_Element(double left, double top)
{
// do whatever
}
}