Setting the native Window the RadWindow appears in on Silverlight 5

6 posts, 1 answers
  1. I
    I avatar
    2 posts
    Member since:
    Mar 2011

    Posted 03 Feb 2012 Link to this post

    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.Content = new TextBlock { Text = "My Content" };

    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: = WindowHostFactory.GetWindowHost(this, _window);


    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);
           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);

    : 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;
                    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()
           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; }
          _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)
                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);
                    var size = ApplicationHelper.ApplicationSize;
                    location.X = Math.Floor((size.Width - presenterSize.Width) / 2);
                    location.Y = Math.Floor((size.Height - presenterSize.Height) / 2);
                    this.UpdatePresenterPosition(location.X, location.Y);

  2. Answer
    Boyan avatar
    758 posts
    Member since:
    Apr 2013

    Posted 09 Feb 2012 Link to this post


    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.

    the Telerik team

    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

  3. Grant
    Grant avatar
    11 posts
    Member since:
    Oct 2011

    Posted 02 Jul 2012 Link to this post

    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. 

  4. Boyan
    Boyan avatar
    758 posts
    Member since:
    Apr 2013

    Posted 05 Jul 2012 Link to this post

    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.

    the Telerik team

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

  5. Simon
    Simon avatar
    3 posts
    Member since:
    Oct 2011

    Posted 21 May 2013 Link to this post

    Is there any workaround for this or updated information on when it might be fixed?

  6. Vladi
    Vladi avatar
    607 posts
    Member since:
    Jun 2012

    Posted 27 May 2013 Link to this post


    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.


    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top