wpf - XAML C# video does not change in size when i resize the form -


running media player opens stretch="none" problem when resize it, want video scale resizing, if media opens @ 640x480, resize 320x240 want video scale, see screenshots below:

so far good, media opens scaled size of video

enter image description here

but when try make screen smaller see other tabs , lost size of video :/

enter image description here

xaml code:

<window x:class="wpfapplication4.mainwindow"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     title="wpf media player" height="300" width="300"     minwidth="300" sizetocontent="widthandheight"     topmost="true">   <grid>     <grid.rowdefinitions>         <rowdefinition height="auto" />         <rowdefinition height="*" />         <rowdefinition height="auto" />     </grid.rowdefinitions>     <toolbar>         <button x:name="button" content="open" click="button_clickopen" />          <separator />         <button x:name="button2" content="play" click="button2_clickplay"/>          <button x:name="button3" content="pause" click="button3_clickpause"/>          <button x:name="button1" content="stop" click="button1_clickstop"/>         <button x:name="button4" content="web" click="button4_clickweb" />     </toolbar>      <mediaelement name="mediaelement1" grid.row="1" loadedbehavior="manual" stretch="uniform" />  <statusbar grid.row="2">     <statusbar.itemspanel>         <itemspaneltemplate>             <grid>                 <grid.columndefinitions>                     <columndefinition width="auto" />                     <columndefinition width="*" />                     <columndefinition width="auto" />                 </grid.columndefinitions>             </grid>         </itemspaneltemplate>     </statusbar.itemspanel>     <statusbaritem>         <textblock name="lblprogressstatus">00:00:00</textblock>     </statusbaritem>     <statusbaritem grid.column="1" horizontalcontentalignment="stretch">         <slider name="slider1"  valuechanged="slider1_valuechanged" />     </statusbaritem>         <statusbaritem grid.column="2">             <slider name="slider2" width="50" height="24" maximum="1" valuechanged="slider2_valuechanged" />         </statusbaritem>     </statusbar> </grid> 

try putting mediaelement inside of viewbox , set stretch property of viewbox uniformtofill.


Comments