2

I have two InkCanvases stacked and I'd like to get the top to pass inking to the bottom. I set the top to ishittestvisible=false but it still receives the inking. Then as a test I set both to false and the top still gets inking...what am I missing?

I created a blank project and it exhibits the same problem. Here's the code:

MainPage.xaml

<RelativePanel>
    <StackPanel Name="stackPanelButtons" Orientation="Vertical">
        <Button Name="buttonTop" Content="T" Height="50" Click="buttonTop_Click"/>
        <Button Name="buttonBottom" Content="B" Height="50" Click="buttonBottom_Click"/>
        <Button Name="buttonTopHit" Content="TH" Height="50" Click="buttonTopHit_Click"/>
        <Button Name="buttonBottomHit" Content="BH" Height="50" Click="buttonBottomHit_Click"/>
    </StackPanel>
    <InkCanvas Name="inkCanvasBottom" RelativePanel.RightOf="stackPanelButtons" Width="500" Height="500"/>
    <InkCanvas Name="inkCanvasTop" RelativePanel.RightOf="stackPanelButtons" Width="500" Height="500" Loaded="inkCanvasTop_Loaded"/>
</RelativePanel>

MainPage.cs

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this.InitializeComponent();
    }

    private void buttonTop_Click(object sender, RoutedEventArgs e)
    {
        if(buttonTop.Content.Equals("T"))
        {
            inkCanvasTop.Visibility = Visibility.Collapsed;
            buttonTop.Content = "t";
        }
        else
        {
            inkCanvasTop.Visibility = Visibility.Visible;
            buttonTop.Content = "T";
        }
    }

    private void buttonBottom_Click(object sender, RoutedEventArgs e)
    {
        if (buttonBottom.Content.Equals("B"))
        {
            inkCanvasBottom.Visibility = Visibility.Collapsed;
            buttonBottom.Content = "b";
        }
        else
        {
            inkCanvasBottom.Visibility = Visibility.Visible;
            buttonBottom.Content = "B";
        }
    }

    private void buttonTopHit_Click(object sender, RoutedEventArgs e)
    {
        if (buttonTopHit.Content.Equals("TH"))
        {
            inkCanvasTop.IsHitTestVisible = false;
            buttonTopHit.Content = "Th";
        }
        else
        {
            inkCanvasTop.IsHitTestVisible = true;
            buttonTopHit.Content = "TH";
        }
    }

    private void buttonBottomHit_Click(object sender, RoutedEventArgs e)
    {
        if (buttonBottomHit.Content.Equals("BH"))
        {
            inkCanvasBottom.IsHitTestVisible = false;
            buttonBottomHit.Content = "Bh";
        }
        else
        {
            inkCanvasBottom.IsHitTestVisible = true;
            buttonBottomHit.Content = "BH";
        }
    }

    private void inkCanvasTop_Loaded(object sender, RoutedEventArgs e)
    {
        addInputs(inkCanvasTop);
        addInputs(inkCanvasBottom);
    }

    private void addInputs(InkCanvas inkCanvas)
    {
        inkCanvas.InkPresenter.InputDeviceTypes = CoreInputDeviceTypes.Pen | CoreInputDeviceTypes.Mouse;
    }
}
  • Hello and welcome to Stack Overflow. Please take a look at [ask] and [mcve] to see how best to reformat your question to meet Stack Overflows guidelines so that we area ble to help you in the best way possible. – Lilith Daemon Apr 11 '16 at 02:31
  • @ChrisBritt your comment is not helpful to me. In my view I have followed those guidelines. Can you elaborate instead of posting a generic response? – Troy Stevenson Apr 11 '16 at 14:06
  • Hello, The issue is that we can't see an [mcve] to determine what your issue is. Please remember that we have no way of knowing what specifically your doing, or how you are calling an API. Often times problems occur from __bad__ api calls, or other logic errors. However, with an MCVE (Which is an example that demonstrates your problem that is fully testable and verifiable) allows us to run your code so that we may attempt to debug it. In addition, some problems are solved merely by creating an mcve as the simplification can often help with spotting simple logic flaws. – Lilith Daemon Apr 11 '16 at 14:47
  • Thank you @ChrisBritt for explaining more. – Troy Stevenson Apr 11 '16 at 15:28
  • You are very welcome. You did a nice job revising your question. Good luck :) – Lilith Daemon Apr 11 '16 at 16:32

0 Answers0