views:

1413

answers:

4

Is it possible with WPF to create a window that has the shape of a circle and uses a playing movie as the background?

A: 

you can have a canvas as your parent container (set to transparent) then add a circle with a media brush as it's background. that should do it. :)

Blounty
+2  A: 

You should just need to throw something like this in your xaml:

<Ellipse Height="80" Width="80">
    <Ellipse.Fill>
     <VisualBrush TileMode="None">
      <VisualBrush.Visual>
       <MediaElement Source="myMovie.wmv" />
      </VisualBrush.Visual>
     </VisualBrush>
    </Ellipse.Fill>
</Ellipse>

Actually making the window round would be more difficult. Have a look at this if you want the window to be round, it should help figure that part out.

HTH

Bryan Anderson
+3  A: 

To make a non-rectangular window, you need to first do three things.

  1. Set Window.WindowStyle to WindowStyle.None
  2. Set Window.AllowsTransparency to True
  3. Set Window.Background to Transparent (or {x:Null})

Now, your window is completely transparent. You can use the other tips in this thread to paint a piece of media onto the window's geometry.

KP Adrian
+2  A: 

Don't use AllowsTransparency, it has very poor performance and a lot of compatibility problems, go to this link for alternatives:

http://blogs.msdn.com/wpfsdk/archive/2008/09/08/custom-window-chrome-in-wpf.aspx

EDIT: there is an example there how to use SetWindowRgn to get rounded corners for a rectangular windows, if you pass an ellipse region instead of a rounded-rect region you will get an elliptic window, it's easy to create a region for any shape you can imagine.

Nir
I don't see how anything in that article applies to this problem OR to "AllowsTransparency"... They're still drawing a rectangular window.
GalacticCowboy