Reputation: 616
I'm currently trying to get three user controls to work together, in place i have a dock panel which I am adding too. However I cant get the layout perfect, I would prefer to not add user control 1 within user control 2.
Edit: Imagine that the image is spelt Achieve and not Acheive.
Upvotes: 0
Views: 83
Reputation: 1233
No, you cannot do that in DockPanel without the ugly margin manipulation. 1 and 2 should be in a Canvas:
<Canvas x:Name="canvas">
<Grid>
<!-- usercontrol 1-->
<TextBlock Text="1"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Grid>
<DockPanel Background="Transparent"
Height="{Binding ActualHeight, ElementName=canvas}"
Width="{Binding ActualWidth, ElementName=canvas}">
<!-- usercontrol 2-->
<TextBlock Text="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</DockPanel>
</Canvas>
Upvotes: 1
Reputation: 1117
If you want Control 1 to be above Control 2 and not be contained in it, put them in a grid and give Control 1 a higher ZIndex:
<Grid>
<Control1 Grid.ZIndex="2" />
<Control2 Grid.ZIndex="1" />
<Control3 Grid.ZIndex="1" />
</Grid>
Here is the MSDN for reference.
Upvotes: 1