This is a migrated thread and some comments may be shown as answers.

Cannot implicitly convert type RadWindow to Window

10 Answers 810 Views
Window
This is a migrated thread and some comments may be shown as answers.
Sergiy
Top achievements
Rank 1
Sergiy asked on 13 Sep 2012, 07:30 AM
Hello, I have got RadWindow created in xaml.
When I try to create this Rad window in code

                var mainWindow = new MainWindow(); // IT'S RADWINDOW
                Application.Current.MainWindow = mainWindow;
                Close();
                Application.Current.MainWindow.Show();

I have an error as:
Cannot implicitly convert type 'SomeProjectName.SomeFolder.MainWindow' to 'System.Windows.Window'

How to solve this problem?

10 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 13 Sep 2012, 07:56 AM
Hello Sergiy,

Please check the following kb article which demonstrates how you can use RadWindow as main Window in WPF:
http://www.telerik.com/support/kb/wpf/window/radwindow-as-main-window.aspx

Also the approach is discussed in details in the following forum thread:
http://www.telerik.com/community/forums/wpf/window/radwindow-as-mainwindow.aspx 

Kind regards,
Yana
the Telerik team

Time to cast your vote for Telerik! Tell DevPro Connections and Windows IT Pro why Telerik is your choice. Telerik is nominated in a total of 25 categories.

0
Ron
Top achievements
Rank 1
answered on 13 Dec 2012, 03:17 PM
I'm having the same issue. The RadWindow cannot be used as a typical Window object. These referenced links only show how to set up the RadWindow, not how to use the RadWindow as a Window object in the code-behind.  Can someone please answer how to use the RadWindow as a Window object in the code-behind?
0
Yana
Telerik team
answered on 18 Dec 2012, 08:36 AM
Hi Ron,

Currently this is the only way to use RadWindow as main Window that we provide. Could you please explain in more details the issues you're experiencing with the approach?

Regards,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Anatoliy
Top achievements
Rank 2
answered on 11 Feb 2013, 09:55 AM
I have the same Exception with using WPF + MEF... RadWindow can't be converted in Bootstraper:
protected override void InitializeShell()
        {
            base.InitializeShell();
            Application.Current.MainWindow = (Window) Shell;
            Application.Current.MainWindow.Show();
        }

Waiting for some advises!

Best regards, Anatoliy
0
Sueleyman
Top achievements
Rank 1
answered on 13 Nov 2015, 10:47 AM

Hi Anatoliy,

 did you find a soultion for this ?

0
Kalin
Telerik team
answered on 16 Nov 2015, 07:59 AM
Hello Sueleyman,

Please find attached a sample project demonstrating how to use RadWindow as MainWindow in a PRISM 5 application.

Hope this helps.

Regards,
Kalin
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Jason
Top achievements
Rank 1
answered on 24 May 2018, 09:10 PM
Has anyone found a solution for this? I'm having a lot of trouble setting the parent Window of my RadWindow since I can't get it to recognize the RadWindow as a System.Windows.Window.
0
Jason
Top achievements
Rank 1
answered on 25 May 2018, 03:26 PM
To elaborate further, the issue is that while Telerik says that RadWindow is a "Window" object, it's not entirely accurate, since RadWindow does not inherit the System.Windows.Window class, instead it inherits System.Windows.WindowBase, which means that if you try and pass a RadWindow to functions like the WPF / Win32 interoperability helper System.Windows.Interop.WindowInteropHelper it fails because the WindowInteropHelper expects an object of the "Window" class, not "WindowBase".

So is there a way of getting a RadWindow as a System.Windows.Window object?
1
Kalin
Telerik team
answered on 28 May 2018, 10:04 AM
Hi Jason,

RadWindow is hosted in transparent WPF Window. You could get the host Window at run time as shown below:
var wpfWindow = Window.GetWindow(radWindow);

If you need it before it is shown, you could use the HostCreated event of RadWindow - you will be able to find the WPF Window instance in the event arguments.

Hope this helps.

Regards,
Kalin
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
1
Jason
Top achievements
Rank 1
answered on 28 May 2018, 04:03 PM
Thank you a ton Kalin! That solved it for me. Had to use the hostcreated event, but from there I could set my radWindow's owner using the interop helper. Cheers!
Tags
Window
Asked by
Sergiy
Top achievements
Rank 1
Answers by
Yana
Telerik team
Ron
Top achievements
Rank 1
Anatoliy
Top achievements
Rank 2
Sueleyman
Top achievements
Rank 1
Kalin
Telerik team
Jason
Top achievements
Rank 1
Share this question
or