Skip to content

WinRT.Interop.WindowNative.GetWindowHandle Exception: The Specified Cast is not Valid #7951

Answered by DarranRowe
frankayars asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, this is by design.
Only Microsoft.UI.Xaml.Window is documented to implement IWindowNative. Basically, only a Window is backed by a Windows API HWND, UIElements aren't, they are more than likely backed by a composition visual element.

The intended way to get graphics content into Xaml is via SurfaceImageSource, VirtualSurfaceImageSource or SwapChainPanel.

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@Monarkos
Comment options

@DarranRowe
Comment options

@Monarkos
Comment options

Answer selected by frankayars
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants