none
TextInputPanel in WPF

    Question

  •  

    Hi,

    I've playing around with InkCanvas (System.Windows.Ink) in WPF and it's working quite well.

    But I'am wondering if there is a similar functionality (special button or a control) in WPF like TextInputPanel.

    Or do I have to use the TextInputPanel form the Mirosoft.Ink namespace?

     

    Thanks.

    Wednesday, December 19, 2007 9:50 AM

Answers

  • Hi CyberX,

     

    there is no WPF-specifc version of TextInputPanel. You can use the one from the Microsoft.Ink namespace in a WPF application - with a few caveats, though, since that one is designed to work with hWnd-based text controls (WPF's text controls are not hWnd-based).

     

    On a related note, there is also the InkAnalysis framework that comes with an API layer that specifically targets WPF (exposed through iawinfx.dll). With that framework you can build your own ink-to-text input experiences in WPF.

     

    Please let me know what scenario you are trying to accomplish.

     

    Thanks!

    Wednesday, December 19, 2007 2:08 PM

All replies

  • Hi CyberX,

     

    there is no WPF-specifc version of TextInputPanel. You can use the one from the Microsoft.Ink namespace in a WPF application - with a few caveats, though, since that one is designed to work with hWnd-based text controls (WPF's text controls are not hWnd-based).

     

    On a related note, there is also the InkAnalysis framework that comes with an API layer that specifically targets WPF (exposed through iawinfx.dll). With that framework you can build your own ink-to-text input experiences in WPF.

     

    Please let me know what scenario you are trying to accomplish.

     

    Thanks!

    Wednesday, December 19, 2007 2:08 PM
  •  

    Hi Stefan,

     

    Thank you for your fast response!

    We are working on a railway application (used inside the train).

    The train driver has to search Stations an fill out forms(text).

     

    I think we will stick on the WPF environment(we have implemented the recognition of gestures already) and will build our own TextInputPanel.

    (the advantage will be possibly that we have full control over the used dictionary).

     

    -Harry

    Wednesday, December 19, 2007 2:41 PM
  • Cool - please post again in this forum if you run into any problems with that approach.

     

    Thanks!

    Wednesday, December 19, 2007 3:36 PM
  • Hi CyberX,

    I think your problem quite stick to mine. I'm developing an app using WPF too, I wanted to implement the inkAnalysis possibility that Stefan mention but i'm experiencing some issues using this feature, and i find the TextInputPanel a bit "old-fashion" when you see the possiblities of WPF.
    So as Stefan said, let us know which way you're going! :-)
    Thursday, December 27, 2007 11:26 AM
  • Hi Steph

     

    My way looks like this:

    (But I really don’t know if it’s the official MS way)

     

    I’am using a InkCanvas (simplified example):

    <InkCanvas Name="aInkCanvas" EditingMode="InkAndGesture" Gesture="OnGesture" Loaded="OnLoaded" StrokeCollected="OnStrokeCollected">

       <InkCanvas.DefaultDrawingAttributes>

           <DrawingAttributes IgnorePressure="False" FitToCurve="True" Color="Red" Width="5"  />

       </InkCanvas.DefaultDrawingAttributes>

    </InkCanvas>

     

    For the analyzing job I use the InkAnalyzer;

    InkAnalyzer aInkAnalyzer;

     

    void OnLoaded(object sender, RoutedEventArgs e)

    {

       aInkAnalyzer = new InkAnalyzer();

       aInkAnalyzer.AnalysisModes = AnalysisModes.AutomaticReconciliationEnabled;

       aInkAnalyzer.ResultsUpdated += new ResultsUpdatedEventHandler(OnResultsUpdated);

    :

    :  (here I’m also defining an AnalysisHintNode because I’m using a context sensitve dictionary. But this is another story)

    :

    }

     

    This event handler adds the strokes an starts the background analyzer

    void OnStrokeCollected(object sender, InkCanvasStrokeCollectedEventArgs e)

    {

       aInkAnalyzer.AddStroke(e.Stroke);

       aInkAnalyzer.BackgroundAnalyze();

    }

     

    Finally the background analyzer calls my

    void OnResultsUpdated(object sender, ResultsUpdatedEventArgs e)

    handler. There you can analyze the results received (e).

     

    As you see I have a         

    void OnGesture(object sender, InkCanvasGestureEventArgs e)

    handler, which is called when a gesture recognition result is available.

     

    Possibly you also would like to implement the OnClear, OnStrokeErasing event handler.

     

    I hope this helps a little bit!

     

    -Harry

     

     

    Saturday, December 29, 2007 11:12 AM
  •  Stefan Wick - MSFT wrote:

    there is no WPF-specifc version of TextInputPanel. You can use the one from the Microsoft.Ink namespace in a WPF application - with a few caveats, though, since that one is designed to work with hWnd-based text controls (WPF's text controls are not hWnd-based).

     

    I am working on a WPF application targeted for a tablet PC running XP or Vista and I would like to utilize the TextInputPanel. Specifically, I'd like to display it anytime my input controls receive focus. My question is, how can I get it work with WPF controls since they aren't hWnd-based controls (i.e., the caveats you mention above)? Microsoft gets it to work somehow because when my WPF TextBox gets focus the Tablet PC Input Panel icon appears near the TextBox which you can click on to display the Input Panel to enter text. I'm curious how they do it.

     

    Tuesday, September 30, 2008 6:49 PM
  • I had this same problem so I wrote a simple class that displays the Text Input Panel anytime the WPF textbox receives focus.  You can download it from my blog post at: http://interactiveasp.net/blogs/natesstuff/archive/2008/10/01/ink-in-wpf-using-textinputpanel-for-text-input.aspx

     

    Hope that helps!

     

    Thanks!

    Nathan Zaugg

    • Proposed as answer by SlalomScottJ Wednesday, August 25, 2010 1:22 PM
    Wednesday, October 01, 2008 6:11 PM
  •  Nathan Zaugg wrote:

    I had this same problem so I wrote a simple class that displays the Text Input Panel anytime the WPF textbox receives focus.  You can download it from my blog post at: http://interactiveasp.net/blogs/natesstuff/archive/2008/10/01/ink-in-wpf-using-textinputpanel-for-text-input.aspx

     

    Hope that helps!

     

    Thanks!

    Nathan Zaugg


    Thanks for the reply! It works like a charm. 


    Thursday, October 02, 2008 5:23 PM
  • Because my application needs to run on both Vista and XP I decided to modify Nathan's class to use PenInputPanel instead of TextInputPanel (I only need the ability to automatically show/hide the input panel, so PenInputPanel contains all the functionality I require). However, I ran into a problem when I created a WPF Window with two TextBox controls and I tried to create a PenInputPanel for each TextBox. When I try to attach the second PenInputPanel to the second TextBox I get a COM exception:

     

    Code Snippet

    A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Ink.dll

     

     

    I was able to reproduce the problem with a simple sample using the managed Microsoft.Ink.dll assembly and a WPF window with two TextBox's:

     

    Code Snippet

    public partial class Window1 : Window

    {

      private PenInputPanel _pip1;

      private PenInputPanel _pip2;

      public Window1()

      {

        InitializeComponent();

      }

      private void Window_Loaded(object sender, RoutedEventArgs e)

      {

        _pip1 = new PenInputPanel(((HwndSource)PresentationSource.FromVisual(textBox1)).Handle);

        _pip2 = new PenInputPanel(((HwndSource)PresentationSource.FromVisual(textBox2)).Handle);

      }

    }

     

    Attaching the second PenInputPanel causes the exception.

     

    Any ideas/suggestions?

     

    Friday, October 03, 2008 6:43 PM
  • Hi Stefan,

    Is it possible for you to put some code or point to an article where I can find how to attach the Microsoft.Ink.TextInput.TextInputPanel to a System.Windows.Control.Textbox?

    Cheers,

    Nilu
    Friday, November 13, 2009 2:48 AM