如何使用 RadWindow 作为 WPF 应用程序的 MainWindow



我想使用 RadWindow 作为我的 WPF 应用程序的主窗口。使外窗也以整体应用为主题。我使用了这种方法,但之后应用程序不再显示在任务栏上。在阅读了不同的线程后,我开始知道,因为RadWindow不是Window的子级,所以这就是为什么它是不可能的。

所以现在我要做的是,以某种方式完全隐藏外部窗口,并将 RadWindow 用作子控件,但所有其他控件的父级。以下是 XAML

<Window x:Class="MyTest.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"
        WindowStyle="None"
        Title="MainWindow" >
    <telerik:RadWindow WindowStartupLocation="CenterScreen" Width="Auto" Height="Auto" x:Name="MyRadWindow">
    <Grid>
      <!-- All Controls here -->
    </Grid>
</telerik:RadWindow>
</Window>

但我无法完全隐藏外窗。它仍然显示边界。然后作为第二步,我必须处理此RadWidow的最小化、最大化和窗口关闭事件。

如果有人尝试过这种方法,请帮助我或建议更好的方法是什么?

执行所有这些操作的主要目的是将Outerwindow的GUI与当前的TelerikTheme同步。

使用 RadWindowInteropHelper 有一个更简单的解决方案,如下所示:

using Telerik.Windows.Controls.Navigation;
public partial class MyRadWindow : RadWindow
{
    public MyRadWindow()
    {
        InitializeComponent();
        RadWindowInteropHelper.SetShowInTaskbar(this, true);
    }
}

我认为您应该尝试将主类设置为telerik窗口,而不是嵌套在普通窗口中:

<telerik:RadWindow x:Class="MyTest.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"
        WindowStyle="None" WindowStartupLocation="CenterScreen" ShowInTaskbar="True"
        Title="MainWindow" >
    <Grid>
      <!-- All Controls here -->
    </Grid>
</telerik:RadWindow>

不要忘记将 MyTest.MainWindow 的基类更改为 RadWindow

编辑:抱歉没有注意到提供的链接。您可以尝试通过设置以下属性来隐藏主窗口并覆盖它样式:

WindowStyle="None" Background="Transparent" AllowsTransparency ="True"
  1. 首先打开 MainWindow.xaml 文件,并将 Window 声明替换为 RadWindow 声明: <telerik:RadWindow x:Class="RadWindowAsMainWindow.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" Loaded="RadWindow_Loaded_1" Header="MainWindow" Height="350" Width="525">... </telerik:RadWindow>

在代码隐藏中: `

public partial class MainWindow : RadWindow
    {
     ...
    }

2. Then override OnStartup method of the Application class to show the RadWindow:

public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            new MainWindow().Show();
            base.OnStartup(e);
        }
    }

'

  1. 然后在 RadWindowLoad 事件中写下以下内容:`

    private void RadWindow_Loaded_1(Object sender, RoutedEventArgs e) { var 窗口 = 这个。ParentOfType(); 窗。显示任务栏 = 真; }

'

最新更新