Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
C++
_display = new Display((IntPtr)videoPanel.handle);

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

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

To know how to use the MediaElement please see here: MediaElement Class[^]
 
Share this answer
 
v2
Comments
bijaynayak 27-Mar-14 10:41am    
Hello Alex, but my requirement is that i am fetching the camera list from the database.so can u tell me what is the possible way to handle this situation by using media element.
The wpf panel control doesn't have handle but you can use windows forms panels in wpf to.

Edit:
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.
XML
xmlns:WinForms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"


than your xaml file would look like something like:

XML
<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>


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

Old:
You could do it in code like
C#
WindowsFormsHost host = new WindowsFormsHost();

host.Child = wfPanel;

this.gridPreview.Children.Add(host);


from url: panle handle in wpf[^]


Or in xaml code

XML
<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>
 
Share this answer
 
v6
Comments
bijaynayak 27-Mar-14 10:45am    
Hello BELGIUMsky,
i try to impliment but not able to play the video
_display = Display((IntPtr)videoPanel.Handle);
where video panel is the object of WindowsFormHost.

i need one clarification how to add the panel to my window in wpf,so that it can be more convenient to solve my issue.
BELGIUMsky 27-Mar-14 10:52am    
In about 2hours and 15min i will be home and try to make an example for you.
Don't have my sample data with me.
bijaynayak 28-Mar-14 3:18am    
Hello BELGIUMsky, i am waiting for the solution. i am also trying but not getting how to do that one
BELGIUMsky 28-Mar-14 3:38am    
I'm sorry had some problems at home that needed my complete attention.

Will update my solution in a couple of minutes
bijaynayak 28-Mar-14 5:38am    
Ok BELGIUMsky i m waiting

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900