我正在WPF \ Telerik項目中工作。我遇到了一個非常奇怪的問題,即由於功能的相互依賴關係,我無法使用解決方法。'[WPFApplication] .MainWindow'的部分聲明不能指定不同的基類
我的項目有一個自動註銷功能,爲此我必須使用這段代碼,如下所示。
private void InitializeAutoLogoffFeature()
{
HwndSource windowSpecificOSMessageListener = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
windowSpecificOSMessageListener.AddHook(new HwndSourceHook(CallBackMethod));
LogOffHelper.LogOffTime = logOffTime;
LogOffHelper.MakeAutoLogOffEvent += new MakeAutoLogOff(AutoLogOffHelper_MakeAutoLogOffEvent);
LogOffHelper.StartAutoLogoffOption();
}
在此HwndSource windowSpecificOSMessageListener = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle);
行代碼我必須通過窗口(this
)。因爲WindowInteropHelper
構造函數只接受Window
類型。
但是當我impliments作爲初級講座
public partial class MainWindow : Window
{
我得到一個錯誤,
Partial declarations of '[WPFApplication].MainWindow' must not specify different base classes
這MainWindow
不是Window
它的一個Telerik window
。
XML如下所示。
<telerik:RadWindow x:Class="[WPFApplication].MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
Header="POS" Height="820" Width="1280"
WindowStartupLocation="CenterScreen">
<telerik:RadWindow.Resources>
..
這是我的App.xaml
<Application x:Class="[WPFApplication].App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow"
>
<Application.Resources>
</Application.Resources>
我也通過使用此代碼嘗試以及在App.xaml.cs
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
new MainWindow().Show();
base.OnStartup(e);
}
}
我應該如何解決這個問題?
我認爲你需要使用不使用'StartupUri' *的方式覆蓋'OnStartup'和* (請參閱http://www.telerik.com/support/kb/wpf/window/radwindow-as-main-window.aspx) –