WPF MediaElement ActualWidth and ActualHeight is always zero

1.3k views Asked by At

For some unknown reason I cannot get my MediaElement to show up when I use it in a ControlTemplate.

I have installed snoop and I have determined that the ActualWidth and ActualHeight is always zero, if I put the same media element on the main window just randomly placed, it does show.

So, why the heck would it always be zero?? This is killing me!!

here is my xaml in the ControlTemplate:

<MediaElement x:Name="frostElement" 
        HorizontalAlignment="Stretch" 
        VerticalAlignment="Stretch" 
        Stretch="Fill"
        LoadedBehavior="Play"
        Width="{TemplateBinding Width}" 
        Height="{TemplateBinding Height}" 
        Margin="0,0,0,26.083" 
        Source="../Images/ice.mpg"/>

Also, if I set the width and height manually, it still doesnt show up.

1

There are 1 answers

0
Mark On BEST ANSWER

Bah! I figured it out, it was a resource issue, I put in the full path to the file (c:..blah) and it worked.