You can do that easily with the ContentProperty attribute.
Then you can define your code behind as:
[ContentProperty("Child")]
public partial class MyControl: UserControl
{
public static readonly DependencyProperty ChildProperty = DependencyProperty.Register("Child", typeof(UIElement), typeof(MyControl), null);
public UIElement Child
{
get { return (UIElement)this.GetValue(ChildProperty); }
set
{
this.SetValue(ChildProperty, value);
this.content.Content = value;
}
}
What that will do is any default content within your tags (<MyControl Text="somecontent">main content </MyControl>
) - will be set as the Child property on your class. Then once it's been set you can assign it to any control you like.
Edit:
You can have as many contents as you like, but you can only have 1 auto-content (which is designated via the ContentProperty attribute).
If you want two you could do:
<MyControl>
<MyControl.Content1>Hello World</MyControl.Content1>
<MyControl.Content2>Goodbye World</MyControl.Content2>
</MyControl>
All you have to do is make sure you have the matching dependency properties in your code. Then when the property is set, just assign it to a parent content control in your XAML.