2013-11-21 59 views
1

我有一个页面,并MediaElement的拉伸就可以了:处理的MediaElement视频

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> 
    <MediaElement x:Name="Player" HorizontalAlignment="Stretch" Margin="0" VerticalAlignment="Stretch" Source="myvideo.mp4"/> 
</Grid> 

当我打开网页,它看起来像这样:

enter image description here

那是因为视频不是与Page相同的尺寸。

好吧,我想延长I设置视框内容:

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> 
    <Viewbox Stretch="UniformToFill" StretchDirection="Both"> 
    <MediaElement x:Name="Player" HorizontalAlignment="Stretch" Margin="0" VerticalAlignment="Stretch" Source="myvideo.mp4"/> 
    </Viewbox> 
</Grid> 

但现在的标志(视频中心)是不是在页面的中心。 如何实现它?

现在看起来是这样的:

enter image description here

从中心偏移只有垂直,平铺看起来像标志保留在中心。

有在MediaElement的扩展选择一个构建,但somewhy当我设置它,它说:未知的成员“拉伸”元素的MediaElement

回答

0

答案是集视框元素的VerticalAligment =“中心”

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> 
<Viewbox VerticalAligment="Center" Stretch="UniformToFill" StretchDirection="Both"> 
<MediaElement x:Name="Player" HorizontalAlignment="Stretch" Margin="0" VerticalAlignment="Stretch" Source="myvideo.mp4"/> 
</Viewbox> 

0

看来,当你设置它喜欢的工作,你想要的方式这样的:

<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"> 
    <MediaElement x:Name="Player" Stretch="UniformToFill Source="myvideo.mp4"/> 
</Grid> 

从MS文档,它看起来像弹力只支持在Windows 8.1:http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.mediaelement.stretch.aspx

+0

NOP,得到的答复是更容易视框的VerticalAligment = “中心” – Cheese