Transparent InkCanvas with Child Controls RRS feed

  • Question

  • Hi, I'm developing a Tablet PC application using WPF.  I have a UserControl that contains an InkCanvas at the top most layer and contains several child controls (TextBoxes, CheckBoxes and ComboBoxes) so the ink always appears on top of the them. 


    Currently, I'm using some hittesting to determine if a stroke was collected over a contorl, such as a TextBox.  If it was, I create an adorner layer to let the user know that the strokes collected will be analyized and added to the adorned control. 


    I also created a "write-ahead" ComboBox, basically the same way, analyzing the strokes that are collected and then selecting the appropriate value from the control's data source.  I also added the ability that if the user taps the stylus over the ComboBox, I set the IsDropDownOpen property to true allowing the popup to appear.  I want to have ability to use the stylus with the dropdown to select values normally and also have the "write-ahead" functionality with the InkCanvas.  My problem is everytime I try and click on the dropdown popup, it automatically closes and a vertical stroke gets drawn on the canvas.


    Does anyone have any thoughts on how to handle this issue or perhaps a better way to approach it all together?


    Thanks in advance,


    Thursday, July 31, 2008 1:55 PM

All replies

  • Hey Kevin,

    One thing you can try is the capture the MouseDown event to the dropdown before the InkCanvas handles it.  Set the e.Handled property for the PreviewMouseDown and also capture the mouse (or stylus).  If you can't do this in the InkCanvas, do your hittesting in the adorner layer over the dropdown which I know for a fact will allow you to intercept those events.  Remember to capture the mouse to prevent the stroke from being added to the InkCanvas.Strokes and set e.Handled = true in your event to prevent the DynamicRenderer from drawing the ink as you move the mouse. 

    Hope this helps,



    Thursday, July 31, 2008 9:28 PM