Prism Region.Activate Problem

12 posts, 1 answers
  1. Heather
    Heather avatar
    54 posts
    Member since:
    Sep 2010

    Posted 27 Sep 2010 Link to this post

    Using:  WPF 4.0, latest trial build of WPF controls

    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>

     

     

     

     

     

  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 30 Sep 2010 Link to this post

    Hi Heather,

    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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Heather
    Heather avatar
    54 posts
    Member since:
    Sep 2010

    Posted 30 Sep 2010 Link to this post

    Yes that is correct.  I expect that if my radtabcontrol is defined as a region that issuing a region.Activate(view) call in code will select the corresponding tab as if someone clicked on it with the mouse.  The WPF TabControl does this correctly but the RadTabControl does not.  I could not attach a project to this item so I created support ticket  #353107 with a project that shows the problem.
  5. Answer
    Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 05 Oct 2010 Link to this post

    Hi Heather,

    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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Joe
    Joe avatar
    15 posts
    Member since:
    Apr 2011

    Posted 31 May 2011 Link to this post

    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

  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 03 Jun 2011 Link to this post

    Hello 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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Heather
    Heather avatar
    54 posts
    Member since:
    Sep 2010

    Posted 22 Jul 2011 Link to this post

    Appears that this has been fixed in the lastest version of the controls (2011 Q2).  Thank you.
  9. Daniel
    Daniel avatar
    6 posts
    Member since:
    Sep 2012

    Posted 09 Oct 2012 Link to this post

    Hi,
    Could you also tell me how to load two instances of the same module in two different tab items.

    Thanks
  10. Hristo
    Admin
    Hristo avatar
    352 posts

    Posted 12 Oct 2012 Link to this post

    Hi,

    I've updated the sample project and attached it.
    Please give it a look and let us know if you need more info.

    Kind regards,
    Hristo
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  11. Daniel
    Daniel avatar
    6 posts
    Member since:
    Sep 2012

    Posted 12 Nov 2012 Link to this post

    This worked fine for silverlight with previous version of rad controls. Now i have version 2012.2.1001.1050 and the header doesn't show.
    Can you please update me on this.

    Thanks
  12. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 15 Nov 2012 Link to this post

    Hi Daniel,

    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.

  13. Daniel
    Daniel avatar
    6 posts
    Member since:
    Sep 2012

    Posted 22 Jan 2013 Link to this post

    It works.Thanks.
Back to Top
UI for WPF is Visual Studio 2017 Ready