wpf中c#面板句柄的替代方法是什么? [英] what is the alternative for c# panel handle in wpf

查看:148
本文介绍了wpf中c#面板句柄的替代方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

_display = new Display((IntPtr)videoPanel.handle);



这里videoPanel是c#中面板的对象但是我需要wpf中的handle属性来处理视频


Here videoPanel is the object of panel in c# but i need handle property in wpf to handle the video

推荐答案

尝试使用MediaElement控件,您可以在WFP中播放视频。

以下示例显示了简单的XAML代码:

Try using MediaElement control you will can play a video in WFP.
The following example shows simple XAML code:
<mediaelement name="VideoControl" width="200" height="400" source="my_file.wmv">    
</mediaelement>



To知道如何使用MediaElement请看这里: MediaElement Class [ ^ ]


wpf面板控件没有句柄,但你可以在wpf中使用windows窗体面板。

< br $>
编辑:

首先你应该添加对

WindowsFormsIntegration(对于WindowsFormsHost)

和System.Windows的引用。表格(面板)。



然后你应该在你的xaml文件中添加一个xmlns。

The wpf panel control doesn't have handle but you can use windows forms panels in wpf to.


First you should add reference to
WindowsFormsIntegration (for the WindowsFormsHost)
and System.Windows.Forms (for the panel).

Then you should add an xmlns to your xaml file.
xmlns:WinForms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"





比你的xaml文件看起来像是这样的:





than your xaml file would look like something like:

<Window x:Class="TestWpf.MainWindow"

        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        xmlns:WinForms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"

        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <WindowsFormsHost>
            <WinForms:Panel x:Name="videoPanel"></WinForms:Panel>
        </WindowsFormsHost>
    </Grid>
</Window>





然后您可以在窗口窗体中使用代码中的面板

videoPanel.Handle



旧:

您可以在代码中执行此操作



then you can use the panel in your code behind like in window forms
videoPanel.Handle

Old:
You could do it in code like

WindowsFormsHost host = new WindowsFormsHost();

host.Child = wfPanel;

this.gridPreview.Children.Add(host);



wpf中的panle句柄 [ ^ ]





或xaml代码





from url: panle handle in wpf[^]


Or in xaml code

<WindowsFormsHost Height="100" HorizontalAlignment="Left" Margin="10,108,0,0" Name="windowsFormsHost1" VerticalAlignment="Top" Width="200">
    <WinForms:Panel BackColor="Red" Dock="Fill">
    </WinForms:Panel>
</WindowsFormsHost>


这篇关于wpf中c#面板句柄的替代方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆