7 Answers, 1 is accepted
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
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.
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
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.
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