首页 > 解决方案 > 避免在 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>

标签: c#wpfwpf-controlswpftoolkitmediaelement

解决方案


推荐阅读