We have an application that uses the docking control. We are using Prism 4 and building the views at runtime from the modules that the user has access to. Each Prism view is a radPane. We have a document host to display details and we are colorizing the background of tabs based upon the module. We're not using the 3100+ lines of xaml template approach that support continually seems to think is a good idea, but instead we are assigning a usercontrol into the header. This gives us a nice way to customize the tab headers as needed.
We need to handle event of when the radPane becomes active so we can set up colors, etc. However there is no .Activated event only the PaneStateChanged event. Since there is no Active property on the radPane, the only way to handle this event is:
- set up PaneStateChanged on the RadDocking, when fired (it should pass a handle to the radPane).
- Then force .Parent to type radPaneGroup
- look at .SelectedRadPane property to see if it is the same as the passed radPane.
However, this approach means we fire this event way more than is needed. The sheer number of times it fires will bog down our application.
Is there a plausible approach to handling the Active event on a radPane?
Thanks,
Paul Congdon
7 Answers, 1 is accepted
The pane activation feature is not present in the current version of the RadDocking control for Silverlight. We implemented it and it will be included in the upcoming beta version and is already published as a pre-beta. You can try the pre-beta here.
Regards,Miroslav Nedyalkov
the Telerik team
I'm building the RadPanes at run-time, and I'm stuffing a UserControl into the header.
I've got 2 routed events on the RadPanes ... one for getting and one for losing focus.
I have a close button in the header in addition to other things.
I've put logging into everything to try to figure out what's going on, and it appears that when the Close button is clicked, the lose-focus event is fired, and I'm not getting the click event for the button.
Does this beta code provide any relief for that scenario?
Thanks!
-Dave
The feature is included in the pre-beta version of the Docking control which could be found here. As working with the focus can put you is a complicated scenarios I would advise you to try the built-in feature.
Greetings,Miroslav Nedyalkov
the Telerik team
I'm also using PRISM4 + MEF with RadDock and have a difficulty to activate specific RadPane among many radpanes in Region,which is RadSplitContainer. For example, after user opened many radPane view in Documenthost, called MainRegion, and he clicked menu again to open radPane which is already existed in MainRegion, then the pane should be changed as selected pane.
In Prism, this is handled at region as follwoings;
public virtual void Activate(object view)
{
ItemMetadata itemMetadata = this.GetItemMetadataOrThrow(view);
if (!itemMetadata.IsActive)
{
itemMetadata.IsActive = true;
}
}
Then region adaptor should deactivate other views in region. This well addressed in RadTabControlRegionAdapter which I got from this thread as followings;
private void OnSelectionChanged(object sender, RoutedEventArgs args)
{
var e = args as RadSelectionChangedEventArgs;
// e.OriginalSource == null, that's why we use sender.
if (this.hostControl == sender)
{
foreach (RadTabItem tabItem in e.RemovedItems)
{
object item = this.GetContainedItem(tabItem);
// check if the view is in both Views and ActiveViews collections (there may be out of sync)
if (this.Region.Views.Contains(item) && this.Region.ActiveViews.Contains(item))
{
this.Region.Deactivate(item);
}
}
foreach (RadTabItem tabItem in e.AddedItems)
{
object item = this.GetContainedItem(tabItem);
if (!this.Region.ActiveViews.Contains(item))
{
this.Region.Activate(item);
}
}
}
}
private void OnActiveViewsChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
this.hostControl.SelectedItem = this.GetContainerForItem(e.NewItems[0], this.hostControl.Items);
}
else if (e.Action == NotifyCollectionChangedAction.Remove
&& this.hostControl.SelectedItem != null
&& e.OldItems.Contains(this.GetContainedItem((RadTabItem)this.hostControl.SelectedItem)))
{
this.hostControl.SelectedItem = null;
}
}
private void OnActiveViewsChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
this.hostControl.SelectedItem = this.GetContainerForItem(e.NewItems[0], this.hostControl.Items);
}
else if (e.Action == NotifyCollectionChangedAction.Remove
&& this.hostControl.SelectedItem != null
&& e.OldItems.Contains(this.GetContainedItem((RadTabItem)this.hostControl.SelectedItem)))
{
this.hostControl.SelectedItem = null;
}
}
Would you provide kind of RadPaneGroupRegionSyncBehavior class or should I make by myself ?
or pls let me advise if simpler way is by behind code. Is this also solved with activate event of RadPane in Q2 ?
Thank you in advance.
Kang
As your region is a SplitContainer and it is not a selector I don't believe it supports activation in the terms of PRISM. I would suggest defining the RadPaneGroup as Region, instead of RadSplitContainer.
Currently we don't have an example demonstrating this behavior, but we are planning to prepare such one in the incoming weeks, most probably after the Q2 release.
Hope this helps.
George
the Telerik team
Hi, Telerik team,
Sorry, I confused with RadPaneGroup with RadSplitContriner.
<telerik:RadDocking Name="radDock">
<telerik:RadDocking.DocumentHost>
<telerik:RadSplitContainer x:Name="documentHost">
<telerik:RadPaneGroup x:Name="mainArea" prism:RegionManager.RegionName="MainRegion">
</telerik:RadPaneGroup>
</telerik:RadSplitContainer>
</telerik:RadDocking.DocumentHost>
<telerik:RadSplitContainer x:Name="leftArea" InitialPosition="DockedLeft">
<telerik:RadPaneGroup prism:RegionManager.RegionName="LeftRegion">
</telerik:RadPaneGroup>
</telerik:RadSplitContainer>
To activate view among in radpanegroup, You mean behind code is the way to go at this time ?
Thank you.
Kang