Using UWP controls in WPF

4

I need to use InkCanvas (which is part of UWP Windows.UI.Xaml.Controls) in a WPF application. I know the WPF has InkCanvas too but they are totally different. The UWP InkCanvas has also InkAnalyzer which I need for handwriting recognition.

I created a fresh WPF app and added references bellow:

  • ...NETCore\v4.5\System.Runtime.WindowsRuntime.dll
  • ...NETCore\v4.5\System.Runtime.WindowsRuntime.UI.Xaml.dll
  • Windows.Foundation.FoundationContract.winmd
  • Windows.Foundation.UniversalApiContract.winmd

In MainWindow.xaml.cs When I try to create a new InkCanvas I get an error:

System.Exception: 'The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))'

public MainWindow()
{
    InitializeComponent();

    Windows.UI.Xaml.Controls.InkCanvas myPage = new Windows.UI.Xaml.Controls.InkCanvas();
}

My question is, is there a way to use UWP controls (especially InkCanvas in my case)in a WPF app?

wpf
xaml
uwp
inkcanvas
asked on Stack Overflow Jan 31, 2018 by suat korkmaz • edited Jan 6, 2019 by Stefan Wick MSFT

1 Answer

5

Not possible today, but it's something that is on the roadmap for a future update.

answered on Stack Overflow Jan 31, 2018 by Stefan Wick MSFT

User contributions licensed under CC BY-SA 3.0