tags:

views:

172

answers:

2

I use the Justin-Josef Angel "way" of cloning controls, but I've run into a problem with data binding: If for example I set the Text property to be bound to something like "{Binding Name}" and then clone the control, the new cloned control will have the text property set to for example Joe (the evaluated value) and not the binding expression.

Anybody have an idea about how to clone a control and have the cloned control be databound?

A: 

Sounds like you're serializing an already-databound control back to xaml in order to deserialize a clone of it. The problem being that the xaml writer doesn't serialize bindings, it evaluates them and serializes the result.

There are two ways around this. First, keep a copy of the original xaml around, with the Binding markup extensions present, and deserialize that. Second, create a TypeConverter that the xaml writer will use to serialize bindings. You can find a couple articles about doing this here and here.

Will
A: 

Hi Will

From what I can see you a referencing WPF right? My question was about Silverlight where there is no functionality for serializing a control back to XAML.

But thanks for your answer.