I'm using the RadTabControl with Prism and cannot get Region.Activate to work. I successfully load multiple views into a RadTabControl that is defined as a Prism Region but when I want to activate one of the views already loaded as below the tab does not get selected as the new active tab.
Private
Sub
ShowChildScreen(
ByVal
param
As
ScreenActivateEventArgs)
If
Not
_screenregistry.ContainsKey(param.ScreenId)
Then
Throw
New
InvalidOperationException(
String
.Format(
"ScreenId {0} not registered."
,
param.ScreenId))
End
If
Dim
s
As
IScreen =
_container.TryResolve(_screenregistry.Item(param.ScreenId))
s.ScreenSubject =
param.ScreenSubject
Dim
reg
As
IRegion =
_regionManager.Regions(param.RegionName)
Dim
v
As
Object
=
reg.GetView(s.ScreenKey)
If
v
Is
Nothing
Then
reg.Add(s.View,
s.ScreenKey)
Else
reg.Activate(v)
End
If
End
Sub
My tab control XAML is as follows:
<
telerik:RadTabControl
cal:RegionManager.RegionName
=
"MainWorkspaceRegion"
Grid.Row
=
"1"
DropDownDisplayMode
=
"Visible"
>
<
telerik:RadTabControl.ItemContainerStyle
>
<
Style
TargetType
=
"{x:Type telerik:RadTabItem}"
>
<
Setter
Property
=
"Header"
Value
=
"{Binding DataContext}"
/>
<
Setter
Property
=
"HeaderTemplate"
>
<
Setter.Value
>
<
DataTemplate
>
<
Grid
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"Auto"
/>
<
ColumnDefinition
Width
=
"Auto"
/>
</
Grid.ColumnDefinitions
>
<
TextBlock
Grid.Column
=
"0"
Text
=
"{Binding DisplayName}"
/>
<
Button
Command
=
"{Binding CloseCommand}"
Grid.Column
=
"1"
Content="X"
Cursor="Hand"
Focusable="False"
FontFamily="Courier"
FontSize="9"
FontWeight="Bold"
Margin="4,1,0,0"
Padding="0"
VerticalContentAlignment="Bottom"
Width="16" Height="16"
/>
</
Grid
>
</
DataTemplate
>
</
Setter.Value
>
</
Setter
>
<
Setter
Property
=
"Height"
Value
=
"25"
/>
<Setter Property="IsSelected" Value="True" />
</
Style
>
</
telerik:RadTabControl.ItemContainerStyle
>
</
telerik:RadTabControl
>
11 Answers, 1 is accepted
Let me double-check whether I fully understand your question. You expect, whenever you activate a view, the associated TabItem to be selected automatically, right? If this is the case, then you have to manually select the right tab whenever a view is activated. For example, let's say you activate a view called "View #1". You have to set the SelectedIndex of the TabControl to 1 in order to select the TabItem.
Let me know if this is what you have in mind. If not, could you please elaborate a little bit more on your scenario. It would also be great if you can send us a small project demonstrating the issue. This way we would be better able to assist you.
Greetings,
Kiril Stanoev
the Telerik team
I've posted a workaround to your support ticket. I'll also attach the workaround project here for the one who might be interested.
All the best,
Kiril Stanoev
the Telerik team
Heather,
I am interested in this "workaround". I am also surprised you used vb for the sample.
I have not worked anywhere that uses vb since C# .NET was released. I do not even install it on my workstations.
Can you describe the example or do I need to install vb on my workstation?
The telerik RadDocking vs. Prism problems are killing me.
I have invested over fifty hours and cannot get ViewInjection (regionManager.RequestNavigate) to work.
Yeah, the new views appear when they are first injected, but the Prism ConfirmNavigationRequest methods are only ever called on the first Injected View. The same methods on the other ones never fire, and no existing view ever becomes the top view when navigating back. I thought about getting a reference from the view model to the view (I know!) to call the view to the top layer, but I cannot get a handle to the the telerik RadPane views from my view models because they are registered without a Name.
I expected telerik to give me productivity gains, but right now telerik has been a huge drain on my productivity. In a few more hours I am going to tell my client I cannot get the product built using telerik.
Sincerely, Joe
In the RadTabControl when you activate a view, it doesn't get selected. This issue is logged in our PITS where you can track its progress. In the meantime you can examine this forum thread where possible workarounds for this issue are discusses. Also there is a feature request to implement a custom RadTabControl RegionAdapter to manage the RadTabControl behavior as a region in PRISM scenarios and you can vote for it here thus increasing its priority.
Also, I attached a sample project illustrating how to use the RadTabControl with MEF and create a custom RegionAdapter for the RadTabControl.
I am sorry to hear about your frustration with using the RadDocking control in a PRISM scenario. But hopefully the attached project will help you implement your scenario.
All the best,
Tina Stancheva
the Telerik team
Could you also tell me how to load two instances of the same module in two different tab items.
Thanks
I've updated the sample project and attached it.
Please give it a look and let us know if you need more info.
Hristo
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Can you please update me on this.
Thanks
The issue is fixed in the latest official release Q3 2012 (v. 2012.3.1017). I attached the Silverlight version of the solution utilizing this release so that you can test it on your side as well. Let me know if it works.
All the best,
Tina Stancheva
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.