我有一页,MediaElement伸到上面:
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<MediaElement x:Name="Player" HorizontalAlignment="Stretch" Margin="0" VerticalAlignment="Stretch" Source="myvideo.mp4"/>
</Grid>当我打开页面时,如下所示:

那是因为视频和Page的大小不一样。
好的,我想扩展设置ViewBox的内容:
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Viewbox Stretch="UniformToFill" StretchDirection="Both">
<MediaElement x:Name="Player" HorizontalAlignment="Stretch" Margin="0" VerticalAlignment="Stretch" Source="myvideo.mp4"/>
</Viewbox>
</Grid>但现在,徽标(视频的中心)不在页面的中心。如何实现?
现在看起来是这样的:

与中心相距仅为垂直,水平看上去像是中心的标志。
在MediaElement中有一个在扩展中构建的选项,但是为什么当我设置它时,它是:元素MediaElement上的未知成员‘拉伸’
发布于 2013-11-28 08:08:50
答案是设置VerticalAligment=元素的ViewBox“中心”
<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>
发布于 2013-11-27 17:09:32
当你像这样设置它时,它似乎按照你想要的方式工作:
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<MediaElement x:Name="Player" Stretch="UniformToFill Source="myvideo.mp4"/>
</Grid>从MS文档来看,只有Windows8.1:http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.mediaelement.stretch.aspx才支持扩展
https://stackoverflow.com/questions/20114563
复制相似问题