Search code examples
wpfxamlvideoresolutionmediaelement

Format and video Resolution like WMP with MediaElement WPF


Hey I would like to know if its possible to do something like that with the MediaElement in WPF: http://img11.hostingpics.net/pics/374632Captur2e.png

And Like that: http://img11.hostingpics.net/pics/403059Capture.png

So I When I resize my window the Default resolution stay the same.

Thanks


Solution

  • Just have a look at the code below. It is a MediaElement in a Border in a Grid. The Border is only there to show that the Grid is filled completely. Running this code and resizing the containing window shows that MediaElement well preserves the aspect ratio of its content (a behaviour that may be altered by setting the Stretch property).

    <Grid>
        <Border BorderThickness="5" BorderBrush="White" Background="Black">
            <MediaElement Source="C:\Users\Public\Videos\Sample Videos\Wildlife.wmv"/>
        </Border>
    </Grid>