Determinate if RadPane's Content is Visible

8 posts, 0 answers
  1. Wojciech
    Wojciech avatar
    2 posts
    Member since:
    Aug 2010

    Posted 16 Dec 2010 Link to this post

    Is any easy way to determinate if RadPane's Content is Visible. I would like to make Lazy Initialization of it.
  2. Wojciech
    Wojciech avatar
    2 posts
    Member since:
    Aug 2010

    Posted 16 Dec 2010 Link to this post

    I have override OnIsSelectedChanged method and write my Own Event.
  3. DevCraft banner
  4. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 20 Dec 2010 Link to this post

    Hello Wojciech,

    We are glad that you have found a solution yourself.
    Just for reference, you can read this forum post in which is explained how the RadDocking is working: http://www.telerik.com/community/forums/silverlight/docking/load-event-fired-each-time-i-switch-on-a-raddocumentpane.aspx#1417977

    Hope this information helps. If you have further questions please let us know.

    All the best,
    Konstantina
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  5. Dean Wyant
    Dean Wyant avatar
    46 posts
    Member since:
    Nov 2009

    Posted 08 Feb 2011 Link to this post

    I would like to know the answer to this question.
    I read the linked thread that talks about visual trees, but it does not tell how a RadPane can determine if it is visible (the selected pane in the group), or the ToolWindow. For instance, I have multiple panes, each charting a different stock's price. They are updated every X seconds. It is a waste to update any that the user cannot see. I would refresh them when they become visible and evey x seconds while they are visible and not refresh them at all if they are not visible.
    The answer to this question would help me do that.
    Thanks.


  6. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 11 Feb 2011 Link to this post

    Hello Dean,

    To determine which pane is selected we have IsSelected property for RadPane, but it affects only the selected pane in a group.

    I would suggest you to workaround this using GotFocus event handler of the RadDocking control and in the body you could do something like this:

    private RadPane lastSelectedRadPane;
       
     private void dock_GotFocus(objectsender, RoutedEventArgs e)
            {
                RadPane pane = (e.OriginalSource asRadPane);
                RadPaneGroup group = (e.OriginalSource asRadPaneGroup);
                if(pane != null&& pane.IsSelected && pane.IsFocused)
                {
                    this.lastSelectedRadPane = pane;
                }
                else
                {
                    if((e.OriginalSource asRadPaneGroup) != null)
                    {
                        RadPane radpane = group.SelectedPane;
                        if(radpane != null)
                        {
                            this.lastSelectedRadPane = radpane;
                        }
                    }
                }
            }

    For more information, I would suggest you to refer to the following forum thread - http://www.telerik.com/community/forums/silverlight/docking/radpane-gotfocus.aspx

    Regards,
    Konstantina
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  7. Dean Wyant
    Dean Wyant avatar
    46 posts
    Member since:
    Nov 2009

    Posted 15 Feb 2011 Link to this post

    I am confused about the GotFocus handling, setting a lastSelectedPane etc. I do not know the purpose of the code. It does not seem suited to lazy initialization or to adding context menu items to the last selected pane.

    As I see it, the issues are:
     1. How to determine if a RadPane is visible to the user (selected pane in group, not auto hidden)
     2. How to get notified when a RadPane becomes visible to the user (selected pane/tab in group, auto un-hide)

    It seems to me the answers are:
    1. If ((IsHidden) || (!IsSelected)) then the pane is not visible to the user. Otherwise, it is.
    Exception: The pane may be covered by a floating pane or an auto show of a pane (mouse over tab when auto hide) and it would still be considered visible to the user. I do not think this is state that matters much.

    2. Override OnIsSelectedChanged and call a custom event.

    public class MyRadPane : RadPane
    {
    public
    delegate void PaneShownEventDelegate(RadPane sender, EventArgs e);
    public event PaneShownEventDelegate PaneShown;
    protected virtual void OnPaneShown()
    {
      if (this.PaneShown != null)
      {
        this.PaneShown(this, EventArgs.Empty);
      }
    }

    protected
    override void OnIsSelectedChanged(bool oldValue, bool newValue)
    {
      if (newValue == true)
        OnPaneShown();
    }
    }
    // Subscribe to the event somewhere
    MyRadPane.PaneShown += new PaneShownEventDelegate(myRadPane_PaneShown);
      
    //Handle the event
    void myRadPane_PaneShown(RadPane sender, EventArgs e)
    {
      //Do whatever
    }

    This seems to work correctly.

    The GotFocus approach does not seem to work when a pane is shown from auto hide. The pane does not get focus in that instance. GotFocus is also called multiple times (like when switching between programs).

    Is there something wrong with this approach?

    Thanks.

  8. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 17 Feb 2011 Link to this post

    Hello Dean,

    The approach seems OK. We are glad that you have achieved the desired behaviour by yourself.

    Please let us know if you have any other concerns about out controls.

    Greetings,
    Konstantina
    the Telerik team
  9. Michael Gaigg
    Michael Gaigg avatar
    9 posts
    Member since:
    Dec 2009

    Posted 17 Apr 2012 Link to this post

    I did implement solution 1 as well - works like a charm!
Back to Top
DevCraft banner