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

Creating a PRISM region adapter for RadTabControl

2 Answers 441 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Anthony
Top achievements
Rank 1
Veteran
Anthony asked on 12 Mar 2018, 02:54 PM

I am converting a .NET 1.1 Windows Form (mdi) based application to a WPF which is using PRISM as its MVVM framework.  

To simulate the mdi behavior, the application needs the ability to open multiple tabs for same view.  For example, I have a view displays the person’s name, address, phone, etc.

I used your CustomTabControlRegionAdapter_WPF project as guidance for  creating the region adapter for the RadTabControl.  This seemed to work until the TabItem view contains another TabsControl.  To ensure it wasn’t something specific with my implementation, I reproduced the behavior in your sample project.

In the TabItemHomeView.xaml , I added the another TabControl:

<TextBlock Text="This is the Home tab content" /><br><telerik:RadTabControl><br><telerik:RadTabItem Header="Tab 1"></telerik:RadTabItem><br>       <telerik:RadTabItem Header="Tab 2"></telerik:RadTabItem><br>       <telerik:RadTabItem Header="Tab 3"></telerik:RadTabItem><br></telerik:RadTabControl>


When the project runs, it  throws an exception on line 215 of the RadTabControlRegionSyncBehavors.cs:  “The region does not contain the specified view.”  Parameter name: view;

Any additional guidance would be appreciated.

Thanks

2 Answers, 1 is accepted

Sort by
0
Anthony
Top achievements
Rank 1
Veteran
answered on 13 Mar 2018, 01:12 PM

I may have identified the fix; however, at this point I don't know if there are any open issues.   I looked at the source code for the PRISM SelectorItemsSourceSyncBehavior.cs to compare the differences.  

 

I replaced line 215: if (!this.Region.ActiveViews.Contains(item))

with    if (this.Region.Views.Contains(item) && !this.Region.ActiveViews.Contains(item))

 

Now that I have been able to create multiple tabs, I feel the TabControl is the wrong control for the top level container.  I no only want to give the user the ability to open up multiple tab, but also to close the tabs and undock them so it behaves like a stand-alone window.   

The RadDocking control seems more appropriate.  I am reviewing the ShellPrism_WPF project in the Docking_WPF solution for PRISM guidance.

 

Thanks

 

0
Petar Mladenov
Telerik team
answered on 15 Mar 2018, 09:20 AM
Hello Anthony,

I am glad to hear you have resolved the exception on your own. Indeed, our example is not well suited for nested TabControls. As for the Docking - yes it is more appropriate when it comes to dock/undock (arrange), float a tab into window, drag-drop operations, closing tabs. In addition to the mentioned sample ShellPrism you can take a look at the following blog post:

How To Use RadDocking with PRISM in WPF / SIlverlight

Regards,
Petar Mladenov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
TabControl
Asked by
Anthony
Top achievements
Rank 1
Veteran
Answers by
Anthony
Top achievements
Rank 1
Veteran
Petar Mladenov
Telerik team
Share this question
or