我想观看全屏视频,我认为它是这样工作的:
<Window x:Class="test.Overlay"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Overlay" Height="300" Width="300" WindowState="Maximized">
<Grid>
<Canvas Name="lightCanvas" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<MediaElement Name="lightMovie" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Source="C:\knoblauch\lights\1.wmv" Stretch="Fill" />
</Canvas>
</Grid>
但出于某种原因,视频(在本例中为 1.wmv)没有填满屏幕。 为什么?
最佳答案
添加到 Canvas 的元素不会相对于 Canvas 调整大小。它们将是它们的非拉伸(stretch)尺寸或已明确设置的尺寸(通过设置宽度、高度等)。要让项目拉伸(stretch),您需要支持该功能的容器,例如网格。
例如:
<Grid>
<MediaElement Name="lightMovie" Source="C:\knoblauch\lights\1.wmv" Stretch="Fill" />
</Grid>
如您所愿。
关于c# - Canvas 中的 MediaElement 不会拉伸(stretch)以填充,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4886850/