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

Setting the native Window the RadWindow appears in on Silverlight 5

10 Answers 236 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
I
Top achievements
Rank 1
I asked on 03 Feb 2012, 11:08 PM

In the existing Telerik RadControls there is no way to programmatically set the window a RadWindow appears in. They always appear in the Main Window. This is an issue for Silverlight 5 Out-of-Browser (OOB) applications making use of multiple windows.

Please introduce a SetWindow function on WindowBase so that the Window the RadWindow appears in can be set. As per the new Silverlight 5 Popup.SetWindow instance method.

For example the following should be possible:

var rw = new RadWindow();
rw.SetWindow(Window.GetWindow(this));
rw.Content = new TextBlock { Text = "My Content" };
rw.ShowDialog();

The value passed to the SetWindow function should be used to determine the RootVisual of the RadWindow using Silverlight 5's new Window.GetWindow static method. It should also be used to set the window of any Popup controls related to the RadWindow.

Alternatively at the very least please honour the Owner property in a multi-window environment.

The following steps describe how this can be achieved against the 2011_3_1220 Silverlight RadControls source:

Solution: Navigation_SL
Project: Controls_SL
Files: WindowBase.cs, WindowHostFactory.cs, MultiplePopupWindowHost.cs

File: Window/WindowBase.cs

Add a window field which defaults to the main window:

private System.Windows.Window _window = System.Windows.Application.Current.MainWindow;

Add a public SetWindow method (with comments):

public void SetWindow(System.Windows.Window window)
{
    _window = window;
}

 

Edit the ShowWindow method to additionally pass the _window field:
this.host = WindowHostFactory.GetWindowHost(this, _window);


File:
Window/InternalWindow/WindowHostFactory.cs

Edit the GetWindowHost method, adding a windowWindow argument and call CreateHost with it:

public static IWindowHost GetWindowHost(WindowBase window, System.Windows.Window windowWindow)
{
       var windowHost = CreateHost(windowWindow);
       windowHost.Setup(window);
       return windowHost;
}

Edit the CreateHost method, adding a window argument and use it to construct the MultiplePopupWindowHost instance:

private static IWindowHost CreateHost(System.Windows.Window window)
 
       return new MultiplePopupWindowHost(window);


File
: Window/InternalWindow/MultiplePopupWindowHost.cs

Add a window field:

private System.Windows.Window _window;

Add a constructor to take the window as an argument:

public MultiplePopupWindowHost(System.Windows.Window window)
{
    _window = window;
}

Edit the GetHostManager method to use the window field:

protected override PopupHostManagerBase GetHostManager()
       {
              if (this.manager == null)
              {
                     var owner = FindRootOwner(this.DragableWindow);
            // Fix begin
            FrameworkElement root;
            if (owner == null)
            {
                root = _window.Content;
            }
            else
            {
                root = ApplicationHelper.GetRootVisual(owner);
            }
            // Fix end
            //var root = ApplicationHelper.GetRootVisual(owner);
            this.manager = new PopupHostManager(root);
              }
 
              return this.manager;
       }

Edit the constructor to call SetWindow on the popup:

public PopupHostManager(FrameworkElement root)
       : base(root)
{
       this.popup = new System.Windows.Controls.Primitives.Popup
       {
             Child = this.Host = new Canvas()
       };
      this.popup.SetWindow(Window.GetWindow(root));
 
       if (root == null)
       {
             this.popup.Opened += this.OnPopupOpened;
       }
 
       this.popup.IsOpen = true;
}

File: Window/RadWindow.cs

When the Owner property value is set so should the window be set:

private ContentControl _owner = null;
/// <summary>
/// Gets or sets the Owner of the RadWindow.This is a dependency property.ull
/// </summary>
public ContentControl Owner
{
   get { return _owner; }
   set
   {
      _owner = value;
      this.SetWindow(Window.GetWindow(_owner) ?? Application.Current.MainWindow);
   }
}

File: Window/InternalWindow/BrowserWindowPresenter.cs 
Method: UpdateStartupLocation

Finally with multiple windows now supported the behaviour of the WindowStartupLocation property when set to CenterScreen needs to be defined. I suggest that it defaults to the center of it's owner's window (rather than appear in a secondary window with the center position from the main window), i.e.:

            if (centerScreen)
            {
#if SILVERLIGHT
            var window = Window.GetWindow(this);
            var plugin =
                window == null
                ? Application.Current.MainWindow.Content as FrameworkElement
                : window.Content;
            var size =
                new Size(plugin.ActualWidth / ApplicationHelper.ZoomFactor,
                         plugin.ActualHeight / ApplicationHelper.ZoomFactor);
#else
                var size = ApplicationHelper.ApplicationSize;
#endif
 
                location.X = Math.Floor((size.Width - presenterSize.Width) / 2);
                location.Y = Math.Floor((size.Height - presenterSize.Height) / 2);
 
                this.UpdatePresenterPosition(location.X, location.Y);
            }

10 Answers, 1 is accepted

Sort by
0
Accepted
Boyan
Telerik team
answered on 09 Feb 2012, 10:13 AM
Hello,

We are aware of this problem. Unfortunately the fix for this issue will not make it for Q1 which is scheduled for next week, but we will make sure that it will be fixed in one of the internal builds after that and will be included in the service pack. I have logged it in our PITS as issue 9680, so you can follow its progress.

Thank you for the detailed explanation and the code. We have added points to your account for the suggestion. Don't hesitate to contact us if you have other questions.

Regards,
Boyan
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Grant
Top achievements
Rank 1
answered on 02 Jul 2012, 05:01 AM
Is there any plan to fix or add this functionality? It is very important for our application to leverage SL5 native windows in OOB mode to support multiple monitors. 
0
Boyan
Telerik team
answered on 05 Jul 2012, 08:43 AM
Hi Grant,

Implementing this functionality was delayed due to more urgent tasks and I am afraid that it is not scheduled for next Q as well. At this moment we can't give you an exact timeframe when support for this functionality will be implemented.

We are sorry for the inconvenience, don't hesitate to contact us if you have other questions.


Regards,
Boyan
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Simon
Top achievements
Rank 1
answered on 22 May 2013, 02:09 AM
Is there any workaround for this or updated information on when it might be fixed?
0
Vladi
Telerik team
answered on 27 May 2013, 09:00 AM
Hello,

As the tasks for our next Q are not fully planed we will consider adding this to our time schedule, unfortunately as this is a case specific issue and we have other tasks with bigger priority we cannot confirm that it would be included in the tasks for the next Q release of RadControls.

We will continue to track the demand for this functionality and do our best to implement it in one of our future versions of RadWindow. Again we apologize for any inconvenience that this maybe causing.

Regards,
Vladi
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Andrew
Top achievements
Rank 1
answered on 28 Apr 2014, 08:12 PM
Has this not been resolved?  I have a SL web app which pops up a RadWindow dialog for entry, and if there are errors, pops up a second  RadWindow alert.  I have set the owner of the second window to be the first, but it still appears behind (preventing the user from selecting the OK button and forcing a page refresh to continue).
0
Vladi
Telerik team
answered on 29 Apr 2014, 10:26 AM
Hi Andrew,

We are not sure what exactly the issue is that you are experiencing.

From what we understand you have a RadWindow opened with the use of the ShowDialog() method and after that another RadWindow is opened from that initial window with the Show() method. In that scenario if the Owner of the second RadWindow is set to be the first one, the second window will always be on top of its parent. This is valid for both OOB and normal Silverlight applications. The previously mentioned issue is related to the possibility of opening RadWindow instances when in OOB application out of the MainPage of the application which is currently not supported in the RadWindow control. This feature request has been logged in our feedback portal and you can vote of it and track its status here.

I created and attached a sample project for you showing how the second RadWindow is correctly placed above its parent. If we have missed something please let us know.

Regards,
Vladi
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Andrew
Top achievements
Rank 1
answered on 29 Apr 2014, 01:59 PM
Vladi-
Thanks for your reply.  I was setting the Owner properly, but was caught by the first window having 'IsTopmost' set to true.  After I removed that setting, the behavior was as expected.
Andrew
0
Sébastien
Top achievements
Rank 1
answered on 11 Jul 2014, 05:26 PM
Any update on this issue ? (to me this is more a bug than a feature... Steps to workaround have been published long time ago...)

Thanks for your reply.
0
Kalin
Telerik team
answered on 14 Jul 2014, 10:46 AM
Hello Sébastien,

I understand your concern. However this Feature Request is not planed for implementation yet. What I can suggest you would be to follow the item in our Feedback portal (you can vote as well if you haven't done it yet). This way you will get notified as soon as its status is changed.

Hope this helps.

Regards,
Kalin
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Window
Asked by
I
Top achievements
Rank 1
Answers by
Boyan
Telerik team
Grant
Top achievements
Rank 1
Simon
Top achievements
Rank 1
Vladi
Telerik team
Andrew
Top achievements
Rank 1
Sébastien
Top achievements
Rank 1
Kalin
Telerik team
Share this question
or