views:

52

answers:

1

Hello everyone,

I am using Silverlight 3.0 + .Net 3.5 + VSTS 2008 + C# to develop a simple video application using MediaElement of Silverlight.

I have two videos and I want to play them at the same time (similar to picture in picture effect) -- i.e. a part of the two videos are overlapped when they are playing (the same concept of Z-Order in UI design). I want to play one MediaElement on top of the other MediaElement, and I am wondering how to assign the overlap order (similar to set Z-Order UI element, but I did not find MediaElement has Z-Order property)?

thanks in advance, George

+1  A: 

George,

you could place your MediaElement inside of a Canvas. The Elements inside a Canvas Element inherit it's Canvas.ZIndex Attribute.

<Canvas x:Name="MediaPlayerPanel" Width="200" Height="200">  
  <MediaElement x:Name="Media1" Height="200" Width="200" Source="file1.wmv" Canvas.ZIndex="1" />
  <MediaElement x:Name="Media2" Canvas.Top="20" Canvas.Left="20" Height="100" Width="100" Source="file2.wmv" Canvas.ZIndex="2" />
</Canvas>

This should work for you!

best regards,
Thomas

moonground.de
How to set ZIndex dynamically in code? And how to set Canvas.Top dynamically in code?
George2
In Silverlight, it's always the best idea to not set anything in Code but use DataBinding. For example, set the Value of Canvas.Top to `{Binding TopProperty}` and define a public Property called TopProperty returning "int". Do you need more instructions? Some general hints on how to use DataBinding: http://msdn.microsoft.com/en-us/library/cc278072%28VS.95%29.aspx
moonground.de
Thanks, question answered!
George2