将 MediaElement 添加到 windows 表单错误 C#

Adding MediaElement to windows form error C#

您好,我最近才发现您可以使用 WPF 中的组件并添加到 windows 表单中,只需创建它们然后将其作为元素主机添加到表单中

所以我想做的是使用 MediaElement 创建一个视频播放器,我也知道您可以使用 Direct X 或使用 Windows 媒体播放器,我想自定义制作一些控件这是我的问题

当我尝试将媒体元素添加到我的 windows 表单时,它给我这个错误

这是我的媒体元素 wpf 代码

<UserControl x:Class="Videoplayer_2._0.MediaPlayer"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:Videoplayer_2._0"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <MediaElement x:Name="mediaElement" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />

    </Grid>
</UserControl>

所以添加 mediaElement 是行不通的,或者我做错了什么,我还在表单中添加了一个 WPF 滑块,因为我不知道它是否会影响它

你只需要重新启动 Visual Studio 我想。