2013-11-21 60 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