views:

53

answers:

2

I'm working on a new presenation component for one of our applications. I am building a Custom WPF Control that just has a DocumentViewer in it and hosting that CC in a Windows Forms application with an ElementHost. I'm using Visual Studio 2008 with C#.

I have customized everything through the XAML to give it the look and feel that integrates it perfecting into our application, but one thing remains...

If you press CTRL+P the print dialog still comes up. I'm at a complete loss as to how to disable that fuction. The use of this CC is to allow the users to pull up and view the Manuals for the systems installed at that site, but we don't want them to accidently print them (100s of pages).

Please help,

-G

+2  A: 

You can always try to consume the keydown event like the following:

private void Window_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.P && (Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
        {
            e.Handled = true; 
        }
    }
Moox
It might be necessary to trap PreviewKeyDown rather than KeyDown, but one of the two should do the trick.
Andy
A: 

Add the following code to the DocumentViewer:

    <DocumentViewer.InputBindings>
        <KeyBinding Key="P" Modifiers="Control" Command="ApplicationCommands.NotACommand" />
    </DocumentViewer.InputBindings>
Christopher Estep
This is exactly what I was looking for. THANK YOU!
Groupal