WPF


For this situation you need to override OnPreviewKeyDown event

override OnPreviewKeyDown( KeyEventArgs e )
{
var uie = e.OriginalSource as UIElement;
switch( e.Key )
{
case Key.Enter:
e.Handled = true;
uie.MoveFocus( new TraversalRequest( FocusNavigationDirection.Next ) );
break;
case Key.System:
if( e.SystemKey == Key.F10 )
{
e.Handled = true;
}
else
{
if( e.SystemKey == Key.F4 && Keyboard.Modifiers == ModifierKeys.Alt )
{
// do somethings
}
}
break;
default:
base.OnPreviewKeyDown( e );
break;
}
}

CrystalReportViewer is a Windows Forms control, you can use
WPF/Windows Form interop technology to integrate the viewer into the
WPF application. Here is the steps you can do.

1. Add a reference to the CrystalDecisions.Windows.Forms.dll.

2. Add a namespace mapping in XAML.

3. Use WindowsFormsHost to host the CrystalReportViewer control.

Sample code:

Code Snippet

<Window

x:Class=”ForumProjects.MainWindow”

xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”

xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml”

xmlns:crystal=”clr-namespace:CrystalDecisions.Windows.Forms;assembly=CrystalDecisions.Windows.Forms”

Title=”MainWindow” Width=”800″ Height=”600″>

<WindowsFormsHost>

<crystal:CrystalReportViewer x:Name=”MyCrystalReportViewer” Width=”300″ Height=”300″/>

</WindowsFormsHost>

</Window>

public partial class MainWindow : Window

{

public MainWindow()

{

InitializeComponent();

// reference CrystalReportViewer in code behind

this.MyCrystalReportViewer.BackColor = System.Drawing.Color.AliceBlue;

}

}