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

时间:2016-03-14 08:12:24

标签: c# wpf windows-forms-designer elementhost

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

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

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

这是我的媒体元素代码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滑块也只是说因为我不知道它是否会影响它

1 个答案:

答案 0 :(得分:0)

我只需要重新启动Visual Studio。