Cannot implicitly convert type RadWindow to Window

11 posts, 1 answers
  1. Sergiy
    Sergiy avatar
    38 posts
    Member since:
    Jan 2012

    Posted 13 Sep 2012 Link to this post

    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?
  2. Answer
    Yana
    Admin
    Yana avatar
    4890 posts

    Posted 13 Sep 2012 Link to this post

    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.

  3. Ron
    Ron avatar
    1 posts
    Member since:
    Oct 2012

    Posted 13 Dec 2012 Link to this post

    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?
  4. Yana
    Admin
    Yana avatar
    4890 posts

    Posted 18 Dec 2012 Link to this post

    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.

  5. Анатолій
    Анатолій avatar
    42 posts
    Member since:
    Oct 2012

    Posted 11 Feb 2013 Link to this post

    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
  6. Sueleyman
    Sueleyman avatar
    6 posts
    Member since:
    Nov 2015

    Posted 13 Nov 2015 in reply to Анатолій Link to this post

    Hi Anatoliy,

     did you find a soultion for this ?

  7. Kalin
    Admin
    Kalin avatar
    1351 posts

    Posted 16 Nov 2015 Link to this post

    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
  8. Jason
    Jason avatar
    11 posts
    Member since:
    Apr 2018

    Posted 24 May 2018 Link to this post

    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.
  9. Jason
    Jason avatar
    11 posts
    Member since:
    Apr 2018

    Posted 25 May 2018 in reply to Kalin Link to this post

    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?
  10. Kalin
    Admin
    Kalin avatar
    1351 posts

    Posted 28 May 2018 Link to this post

    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.
  11. Jason
    Jason avatar
    11 posts
    Member since:
    Apr 2018

    Posted 28 May 2018 in reply to Kalin Link to this post

    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!
Back to Top