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

时间:2021-03-27 15:53:14

Hi i just recently found out that you can use components from WPF and add into windows form just by creating them and later adding then into the form as element Host

您好我刚刚发现您可以使用WPF中的组件并通过创建它们添加到Windows窗体中,然后将其添加到窗体中作为元素主机

So what i am trying to do is to create a video player using MediaElement and i also know that you can use Direct X or use Windows Media player for this put i want to custom make some controls in this so here is my question

所以我想要做的是创建一个使用MediaElement的视频播放器,我也知道你可以使用Direct X或使用Windows Media播放器这个我希望自定义一些控件,所以这里是我的问题

when i try to add a the media element into my windows form it give me this error 将MediaElement添加到Windows表单错误C#

当我尝试将媒体元素添加到我的窗体中时,它会给我这个错误

here's my code for the mediaelement wpf

这是我的mediaelement 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>

So is adding mediaElement just doesn't work or i did something wrong and also i added a WPF slider into the form also just saying because i have no idea if it will affect it or not

所以添加mediaElement只是不起作用或我做错了,我也添加了一个WPF滑块到表单也只是说因为我不知道它是否会影响它

1 个解决方案

#1


0  

You just need to restart Visual Studio I think.

您只需要重新启动Visual Studio。

#1


0  

You just need to restart Visual Studio I think.

您只需要重新启动Visual Studio。