How to get a handle to a User-Control in WPF

We are in the process of integrating a 3rd-party video application with our software.  

Our UI for the video is being done in a WPF user-control.  The API from the 3rd-party requires a handle to the Image control in our user-control so the API can "draw" video to the control.

We're struggling with how to obtain the handle for the Image control inside the user-control.

Any help is greatly appreciated.
LVL 11
CMYScottAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roshan DavisCommented:
if you know the Control ID of that image
userCtril.FindControl("Control ID") should work
0
Roshan DavisCommented:
can can you expose a property in your user control that returns the Handle of the imageCtrol?
public System.IntPtr32 ImageHandle
{
   get
   {
      return imageControl.Handle;
   }
}

Open in new window

0
CMYScottAuthor Commented:
@roshmon

Unless I'm missing something - the problem is that the WPF controls do not expose a 'Handle' property at all
0
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Roshan DavisCommented:
can you try this

HwndSource source = PresentationSource.FromVisual(imageControl) as HwndSource;

Open in new window

0
CMYScottAuthor Commented:
I can - but I don't see how that relates to giving me the handle to the control?

PresentationSource doesn't seem to have a property that exposes the handle.
0
Roshan DavisCommented:
HwndSource source = PresentationSource.FromVisual(imageControl) as HwndSource;
IntPtr32 handle = source.Handle;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
For more info see:
http://msdn.microsoft.com/en-us/library/system.windows.interop.hwndsource.aspx

    "The HwndSource class is designed for general interoperability and is not designed as a managed HWND wrapper. In general, it does not provide managed methods for manipulating the window or properties for inspecting its state. Instead, the HwndSource class provides access to the Win32 window handle (HWND) through the Handle property, which can be passed by means of PInvoke techniques to Win32 APIs in order to manipulate the window."
0
CMYScottAuthor Commented:
It's still not working 100% - the video is being 'drawn' into the entire parent-window of the control, perhaps the API we're using is doing that though.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.