Answered by:
Overlay Problem

Question
-
I have two <ContentControl x:Name="c1" ...> and <ContentControl x:Name="c2" ...>, these two have intersection.
But it was weird that sometimes c1 content was overlay displayed on c2 and sometimes c2 content was overlay displayed on c1.
Can I make this overlay fixed? I have tried to set BringToFront in c1 but did not make effect.
Charlie Chang L
- Moved by Rob Caplan [MSFT]Microsoft employee, Moderator Saturday, August 18, 2012 5:09 AM (From:UI Design for Metro style apps)
Saturday, August 18, 2012 4:07 AM
Answers
-
Hello,
I am not able to reproduce your issue. Here is the XAML that I am using:
<Grid> <ContentControl x:Name="C1" HorizontalAlignment="Left"> <StackPanel> <MediaElement x:Name="_meTop" HorizontalAlignment="Left" Height="257" Margin="281,182,0,0" VerticalAlignment="Top" Width="299" IsLooping="True" Source="Assets/Test2.wmv" PosterSource="Assets/Logo.png"/> <TextBlock>This is a test</TextBlock> </StackPanel> </ContentControl> <ContentControl x:Name="C2" HorizontalAlignment="Left"> <StackPanel> <MediaElement x:Name="_meBottom" HorizontalAlignment="Left" Height="257" Margin="350,282,0,0" VerticalAlignment="Top" Width="299" IsLooping="True" Source="Assets/Test1.wmv" PosterSource="Assets/Logo.png"/> <TextBlock>This is also a test</TextBlock> </StackPanel> </ContentControl> </Grid>
Please try this XAML in your environment and let me know if you are able to reproduce the issue. Keep in mind that the MediaElement has a transparent background. Because of this if the top ME is not playing content you will be able to see the bottom ME content through it.
Thanks,
James
Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
- Proposed as answer by James Dailey - MSFTMicrosoft employee, Moderator Tuesday, August 21, 2012 10:38 PM
- Marked as answer by Jesse Jiang Monday, September 10, 2012 6:47 AM
Tuesday, August 21, 2012 10:38 PMModerator
All replies
-
Hello Charlie,
I need some additional information form you.
1) What type of object are you using in your content control?
2) When does the juxtaposition of controls occur? In other words does this happen when you update the content of the control?
3) Is there a specific reason that you are using a content control? Typically the content control class is used to derive other classes.
Thanks,
James
Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
Tuesday, August 21, 2012 12:38 AMModerator -
1) The MediaElement is embedded inside the content control. Some StackPanel may have been also inside. 2) One MediaElement may overlay on another one. When Source was updated the hided MediaElement may displayed. 3) I used content control for some transformation. I think content control is required. I do not need to derive other classes. I can not find something like "always on the top". Thanks.
Charlie Chang L
Tuesday, August 21, 2012 1:56 AM -
Two ways with Xaml to enforce "On Top":
1. Order your components in a hierarchy (the inside ones are "on top" the others.)
2. If you have two items on the same hierarchical level that overlap, and you want one to always be above the other, increase it's Z.
(As a side note from WPF, which I have not tested with "Metro", if you have two things in a list it appears to draw the last one first, but I might just be nuts.)
Hope this helps
Jim Tomasko
Tuesday, August 21, 2012 7:26 AM -
Hello,
I am not able to reproduce your issue. Here is the XAML that I am using:
<Grid> <ContentControl x:Name="C1" HorizontalAlignment="Left"> <StackPanel> <MediaElement x:Name="_meTop" HorizontalAlignment="Left" Height="257" Margin="281,182,0,0" VerticalAlignment="Top" Width="299" IsLooping="True" Source="Assets/Test2.wmv" PosterSource="Assets/Logo.png"/> <TextBlock>This is a test</TextBlock> </StackPanel> </ContentControl> <ContentControl x:Name="C2" HorizontalAlignment="Left"> <StackPanel> <MediaElement x:Name="_meBottom" HorizontalAlignment="Left" Height="257" Margin="350,282,0,0" VerticalAlignment="Top" Width="299" IsLooping="True" Source="Assets/Test1.wmv" PosterSource="Assets/Logo.png"/> <TextBlock>This is also a test</TextBlock> </StackPanel> </ContentControl> </Grid>
Please try this XAML in your environment and let me know if you are able to reproduce the issue. Keep in mind that the MediaElement has a transparent background. Because of this if the top ME is not playing content you will be able to see the bottom ME content through it.
Thanks,
James
Windows Media SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
- Proposed as answer by James Dailey - MSFTMicrosoft employee, Moderator Tuesday, August 21, 2012 10:38 PM
- Marked as answer by Jesse Jiang Monday, September 10, 2012 6:47 AM
Tuesday, August 21, 2012 10:38 PMModerator