Hey all,

I was wondering if there is a way to put content into a User Control. I can
do it using a Custom Control, but haven't figured out how to set the content
property (can be of the user control, or of its base class). I've used the
new keyword on a dependancy property and can assign things to the property
such as a <Button /> but it doesn't seem to want to render the xaml into the
user control.

Have tried a ContentPresenter and a ContentControl but it wont work. Can't
seem to find a specific example of this so not sure if its even possible.



namespace Controls {

[ContentProperty("Content")]

public partial class Container : UserControl {

public Container() {

InitializeComponent();

}

public new object Content {

get { return (object)GetValue(ContentProperty); }

set { SetValue(ContentProperty, value); }

}

// Using a DependencyProperty as the backing store for Content. This enables
animation, styling, binding, etc...

public new static readonly DependencyProperty ContentProperty =

DependencyProperty.Register("Content", typeof(object), typeof(Container),
new PropertyMetadata(null));

}

}


<UserControl x:Class="Controls.Container"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation";

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml";>

<Grid x:Name="LayoutRoot" Background="White">

<Canvas x:Name="detatchedVideoWindow" Width="640" Height="480" Canvas.Left
="-150" Canvas.Top="400" RenderTransformOrigin="0.5,0.5">

<ContentPresenter x:Name="theContent" Content="{Binding Content}" />

</Canvas>

</Grid>

</UserControl>

sorry about the horrible formatting

thanks,
Stephen



------------------------------------------------------------------- 
OzSilverlight.com - to unsubscribe from this list, send a message back to the 
list with 'unsubscribe' as the subject.
Powered by mailenable.com - List managed by www.readify.net

Reply via email to