c# - 避免在 MediaElement 之前显示空白窗口
问题描述
我创建了一个 WPF C# 应用程序。我在其中放了一个播放视频的 MediaElement。当我运行该应用程序时,会显示一个作为 MediaElement 父窗口的空白窗口一两秒,然后视频开始播放。我不想显示这个空白窗口。我只是想直接显示视频。有谁知道如何解决这个问题,请帮助。提前致谢。
<Window x:Class="MyWindow.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MyWindow"
mc:Ignorable="d"
Title="" Height="2160" Width="3840"
WindowState="Maximized"
WindowStartupLocation="CenterScreen"
Loaded="Window_Loaded"
WindowStyle="None"
AllowsTransparency="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="320*"/>
<RowDefinition Height="50*"/>
</Grid.RowDefinitions>
<MediaElement x:Name="MediaPlayer" Grid.RowSpan="2" LoadedBehavior="Manual" Loaded="MediaPlayer_Loaded" MediaEnded="MediaPlayer_MediaEnded" Source="Video.mp4" Margin="0,0,0,0"/>
<Label Name="My_Content" Content="My Content" Width="500" Height="100" HorizontalAlignment="Center" VerticalAlignment="Bottom" Canvas.Top="1598" Foreground="White" FontSize="48" FontFamily="font_family" FontWeight="Regular" Margin="1666,0,1666,30"/>
<Label Name="My_Label" Content="My Label" Width="1000" Height="100" Canvas.Top="10" Foreground="White" FontSize="48" FontFamily="font_family" FontWeight="Regular" Margin="1376,46,1456,145" Grid.Row="1"/>
<Image Name="My_Image" Source="Photo.png" InkCanvas.Top="530" InkCanvas.Left="2330" Width="1400" Height="660"/>
</Grid>
</Window>
解决方案
推荐阅读
- typescript - 打字稿 - 为什么通用字典类型不返回可能未定义的值?
- javascript - 如何在 JS 中将键值搜索到多维数组中?
- tableau-api - 在画面中追加列
- tomcat - 如何将“Referrer-Policy”和“Feature-Policy”标头添加到 Jira 8 的 Tomcat
- sql - 我可以逐行编写数据库查询的结果并跳过 Python 3 中的数据帧吗?
- postgresql - K8S使用volume来保存DB数据
- gdb - 为什么 GDB 会更改给定地址中的内容?
- vuetify.js - 如何在 Vuetify 2.0.5 中设置 v-sheet/v-container 大小以匹配屏幕与 v-app-bar?
- haskell - 如何将 atomicModifyIORef 与不纯函数一起使用?
- linux - 如何将变量替换为 bash 脚本,然后在 Linux 中的远程服务器上运行