Hi Ulisses,
UlissesP:Although there's a lot of information about Content Controls, most examples are only compatible with the Beta Versions of Silverlight or are just using one Content control, that since it's the Default Content Control it does not need to be named.
Do you want to use tow ContentControls in the user control, and named one contentControl and using it with code?
You can try to refer below code,
1. The xaml code with two ContentControls.One has the name, the othere does not have.
<UserControl
x:Class=”Simple.Page”
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”
Background=”Olive” Width=”400″ Height=”300″>
<UserControl.Resources>
<DataTemplate x:Key=”Circle”>
<Ellipse Width=”20″ Height=”20″ Fill=”Red”></Ellipse>
</DataTemplate>
</UserControl.Resources>
<Grid x:Name=”LayoutRoot” Background=”White”>
<Popup x:Name=”MyPopup”IsOpen=”False”>
<ContentControl ContentTemplate=”{StaticResource Circle}” Opacity=”0.5″/>
</Popup>
<ContentControl ContentTemplate=”{StaticResource Circle}” x:Name=”MyControlToMove” />
</Grid>
</UserControl>
2. then you can use the ContentControl MyControlToMove in the code, like below:
void LayoutRoot_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (!_captured) return;
MyPopup.ReleaseMouseCapture();
MyPopup.IsOpen = false;
_captured = false;
GeneralTransform gt = this.TransformToVisual(MyControlToMove);
PointstartPoint = gt.Transform(new Point(0, 0));
Pointp = e.GetPosition(null);
TranslateTransformtt = new TranslateTransform();
tt.X = p.X - _horisontalOffset - startPoint.X;
tt.Y = p.Y - _verticalOffset - startPoint.Y;
MyControlToMove.RenderTransform = tt;
}
Amanda Wang
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.