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

Determinate if RadPane's Content is Visible

7 Answers 136 Views
Docking
This is a migrated thread and some comments may be shown as answers.
Wojciech
Top achievements
Rank 1
Wojciech asked on 16 Dec 2010, 11:51 AM
Is any easy way to determinate if RadPane's Content is Visible. I would like to make Lazy Initialization of it.

7 Answers, 1 is accepted

Sort by
0
Wojciech
Top achievements
Rank 1
answered on 16 Dec 2010, 01:20 PM
I have override OnIsSelectedChanged method and write my Own Event.
0
Konstantina
Telerik team
answered on 20 Dec 2010, 02:17 PM
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
0
Dean Wyant
Top achievements
Rank 1
answered on 08 Feb 2011, 10:34 PM
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.


0
Konstantina
Telerik team
answered on 11 Feb 2011, 10:42 AM
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>>
0
Dean Wyant
Top achievements
Rank 1
answered on 15 Feb 2011, 09:39 PM

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.

0
Konstantina
Telerik team
answered on 17 Feb 2011, 11:06 AM
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
0
Michael Gaigg
Top achievements
Rank 1
answered on 17 Apr 2012, 05:39 PM
I did implement solution 1 as well - works like a charm!
Tags
Docking
Asked by
Wojciech
Top achievements
Rank 1
Answers by
Wojciech
Top achievements
Rank 1
Konstantina
Telerik team
Dean Wyant
Top achievements
Rank 1
Michael Gaigg
Top achievements
Rank 1
Share this question
or