如何让 MediaElement 占据整个 space 的 Grid?
how to make MediaElement to take the whole space of a Grid?
我在 Grid 中有一个 MediaElement,我希望它在我播放时占据整个 space。
这是我的代码:
<Grid Grid.Row="2" Grid.ColumnSpan="2">
<Grid.Background>
<ImageBrush ImageSource="Resource/bgrdMedia.png" Stretch="None"/>
</Grid.Background>
<MediaElement x:Name="VideoControl" LoadedBehavior="Manual" UnloadedBehavior="Stop"
Stretch="Uniform" StretchDirection="DownOnly" MediaEnded="Element_MediaEnded"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />
</Grid>
但我有:
任何想法!谢谢!
通过将 StretchDirection
设置为 DownOnly
,您可以防止它向上扩展:
DownOnly | The content scales downward only when it is larger than the parent. If the content is smaller, no scaling upward is performed.
如果您将 StretchDirection
保留为 Both
(默认值)并将水平和垂直对齐方式设置为 Stretch
(您拥有的),它应该会给出您想要的结果。
但是请注意,如果原始媒体的分辨率不够高,则放大可能会导致图像模糊或像素化。
我在 Grid 中有一个 MediaElement,我希望它在我播放时占据整个 space。 这是我的代码:
<Grid Grid.Row="2" Grid.ColumnSpan="2">
<Grid.Background>
<ImageBrush ImageSource="Resource/bgrdMedia.png" Stretch="None"/>
</Grid.Background>
<MediaElement x:Name="VideoControl" LoadedBehavior="Manual" UnloadedBehavior="Stop"
Stretch="Uniform" StretchDirection="DownOnly" MediaEnded="Element_MediaEnded"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" />
</Grid>
但我有:
任何想法!谢谢!
通过将 StretchDirection
设置为 DownOnly
,您可以防止它向上扩展:
DownOnly | The content scales downward only when it is larger than the parent. If the content is smaller, no scaling upward is performed.
如果您将 StretchDirection
保留为 Both
(默认值)并将水平和垂直对齐方式设置为 Stretch
(您拥有的),它应该会给出您想要的结果。
但是请注意,如果原始媒体的分辨率不够高,则放大可能会导致图像模糊或像素化。