tags:

views:

176

answers:

0

Hello,

I would like to ask you some help in creating a code the is able to clone a FrameworkElementFactory object created at runtime with the code.

Dim cellTemplateFactory As New FrameworkElementFactory(GetType(NumericTextBox))
cellTemplateFactory.SetValue(NumericTextBox.TypeCodeProperty, Type.GetTypeCode(GetType(Byte)))

Dim b As New Binding("Age") With {.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged}
cellTemplateFactory.SetBinding(NumericTextBox.TextProperty, b)

I tried cloning with:

Public Shared Function CloneObjectUsingXaml(ByVal xamlObject As Object) As Object
    Dim xaml As String = XamlWriter.Save(xamlObject)
    Return XamlReader.Load(New XmlTextReader(New StringReader(xaml)))
End Function

but it throws an exception.

And moreover when I call the SetValue and SetBinding methods of a FrameworkElementFactory instance, where are stored the parameters?

Thank you in advance, Marco