【问题标题】:Adding MediaElement to windows form error C#将 MediaElement 添加到 windows 窗体错误 C#
【发布时间】:2016-03-14 08:12:23
【问题描述】:

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

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

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

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

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

【问题讨论】:

  • 你只需要重启 Visual Studio 我认为
  • 哈哈它工作@Gopichandar谢谢
  • 另外,请确保在 WPF 的 WindowsFormsHost 中添加 winform 控件

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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-26
    • 1970-01-01
    • 2016-04-19
    • 2017-05-21
    • 2023-04-07
    • 1970-01-01
    • 1970-01-01
    • 2020-10-19
    相关资源
    最近更新 更多