Floating window over existing window - any ideas

5 posts, 1 answers
  1. Jonathan
    Jonathan avatar
    7 posts
    Member since:
    Jan 2014

    Posted 25 Jun 2015 Link to this post

    Any ideas how I can create a small floating window (modal) over and existing WPF window?

    I want to show a digital clock on the window/form at all times.

     

    thanks in advance

  2. Nasko
    Admin
    Nasko avatar
    586 posts

    Posted 26 Jun 2015 Link to this post

    Hello Jonathan,

    What we could suggest you in order to achieve the desired is to create an instance of RadWindow and set its Owner property to the MainWindow before calling its ShowDialog method - thus the RadWindow will always be on top of their parent:
    RadWindow window = new RadWindow();
    ...
    window.Owner = this;
    window.ShowDialog()

    Hopes this helps.

    Regards,
    Nasko
    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jonathan
    Jonathan avatar
    7 posts
    Member since:
    Jan 2014

    Posted 26 Jun 2015 in reply to Nasko Link to this post

    On showdialog I get

     

    An unhandled exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll

    Additional information: Cannot set Owner property to a Window that has not been shown previously.

     

     

          public DashBoard()
            {
                InitializeComponent();


                Clock clock = new Clock();
                clock.Owner = this;
                clock.ShowDialog();

     

    Any ideas?  thanks!

  5. Answer
    Nasko
    Admin
    Nasko avatar
    586 posts

    Posted 26 Jun 2015 Link to this post

    Hello Jonathan,

    The thrown exception is an expected one as you are trying to set the Owner property to a Window that is not yet initialized and visualized completely. We suggested you to handle the Loaded event of the Window and create RadWindow inside it - thus it will be sure that the Window is completely loaded:
    public MainWindow()
    {
        InitializeComponent();
        this.Loaded += MainWindow_Loaded;
    }
     
    void MainWindow_Loaded(object sender, RoutedEventArgs e)
    {
        RadWindow window = new RadWindow();
     
        window.Owner = this;
        window.Show();
    }

    Hopes this helps.

    Regards,
    Nasko
    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
  6. Jonathan
    Jonathan avatar
    7 posts
    Member since:
    Jan 2014

    Posted 26 Jun 2015 in reply to Nasko Link to this post

    thanks again!!!
Back to Top
UI for WPF is Visual Studio 2017 Ready