RadRibbonView Prism Support Contextual

11 posts, 0 answers
  1. Bryan
    Bryan avatar
    2 posts
    Member since:
    Jul 2011

    Posted 10 Aug 2011 Link to this post

    I have been working on enabling prism support on your Silverlight RadRibbonView which is simple if you don't need to support injected Contextual tabs. When injecting contextual tabs it requires you also create the RadRibbonContextualGroup which controls the tab's color and visibility. To over come this problem I was going to create a new RadRibbonContextualTab which would extend RadRibbonTab. I was hoping that this new class could find/create the RadRibbonContextualGroup but it can't get it's ParentRibbon control. I noticed in the debugger that there is a non-public property named "ParentRibbon", is there any way to get to this property?? Do you have any example which enabled Prism support for the RadRibbonView?

    Thanks in advance,
    Bryan
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 10 Aug 2011 Link to this post

    Hello Bryan,

    I am not really sure how you add contextual groups and contextual tabs in your scenario and thsi is why I attached a sample project demonstrating how to use the RadRibbonView as a region in a PRISM scenario. The RadRibbonView control has one ContextualGroup and there is a module that is used to load a RadRibbonTab as a contextual tab in that group.

    Basically in the RibbonView the contextual tabs are RadRibbonTabs that have a ContextualGroupName property set. Based on that property the RibbonTab can be displayed in a ContextualGroup - the group wich x:Name property matches the RibbonTab.ContextualGroupName property.

    I hope this information helps.

    All the best,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  3. DevCraft banner
  4. Tej
    Tej avatar
    1 posts
    Member since:
    Aug 2012

    Posted 06 Jun 2012 Link to this post

    Hi,

    I am trying to evaluate RadRibbonView with Prism in Silverlight 5. I downloaded the sample code provided here. But, getting build errors when I try to build and run the application.

    Following is the error message I am getting:  "Error 37 The type or namespace name 'Telerik' could not be found (are you missing a using directive or an assembly reference?) 

    I am using trail version of the "Silver Light Telerik controls".

    I tried by removing the references to telerik dlls and adding them again pointing to "C:\Program Files (x86)\Telerik\RadControls for Silverlight Q1 2012 SP1\Binaries\Silverlight" , but still getting the same errors.

    Can any one help me in figuring out the issue?

    Thanks,
    Tej

  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 07 Jun 2012 Link to this post

    Hello,

    It seems there is an issue with the referenced assemblies, so I want to thank Tej for bringing it to our attention. Due to this issue, I updated the solution to reference the assemblies from the Q1 2012 SP1 release. Also, please keep in mind to set the Shell.Web project as a start-up project of the solution.

    Hope this helps.

    All the best,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Rishabh
    Rishabh avatar
    10 posts
    Member since:
    Jun 2012

    Posted 07 Jun 2012 Link to this post

    Hi Tina,

    I have an issue with the contextual tabs when using MVVM. I also encounter this issue in the project you have attached(the first one).

    The issue is: in the GroupHeaderTemplate, if we provide an ItemTemplateSelector to select the Template for the contents of the RadRibbonGroup, the appropriate Template is not generated, only a TextBlock is generated. This seems to be a bug as I've used the same ItemTemplateSelector for non-contextual tabs and their contents are generating fine. Also, if we don't use the ItemTemplateSelector and instead give an ItemTemplate, the contents are generating fine.

    This is the code that causes the problem.
    <telerik:HierarchicalDataTemplate x:Name="GroupHeaderTemplate"
                   ItemsSource="{Binding Buttons}"
                   ItemTemplateSelector="{StaticResource groupsSelector}">
        <TextBlock Text="{Binding Text}" />
    </telerik:HierarchicalDataTemplate>


    I encountered this issue in a project and was searching related to it. Then I came across the sample you attached and encountered the same issue.

    Steps to reproduce:
    1. Build and run the project.
    2. Open any contextual tab
    3. Click Add Button
    Result - A button is added to a group in the selected contextual tab but if you hover over it, it would be clear that it is not actually a button. Also, when you check the UI with UI Spy, it becomes clear that the added element is a TextBlock and not a RadButton or any other desired Template Item.
  7. Viktor Tsvetkov
    Admin
    Viktor Tsvetkov avatar
    382 posts

    Posted 12 Jun 2012 Link to this post

    Hello Rishabh,

    I have logged this issue in our PITS under the name "RibbonView: ItemTemplateSelector not working for contextual tabs" and it will be ready for tracking and voting tomorrow the latest. I have updated your Telerik points.

    Kind regards,
    Viktor Tsvetkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  8. Deepak
    Deepak avatar
    4 posts
    Member since:
    Jul 2012

    Posted 19 Jul 2012 Link to this post

    Hi ,

    This issue is becoming a show stopper for me... Is there a work around for this? Basically I have a Prism-MVVM applications. Each Module injects a Contextual Tab. The Groups and Buttons are added as per th eattached code. I do not see the Buttons for reasons mentioned above. I just see teh groups...  I checked PITS and thsi is not being resolved. Is there a work around for this?


    Thanks,

  9. Deepak
    Deepak avatar
    4 posts
    Member since:
    Jul 2012

    Posted 19 Jul 2012 Link to this post

    Rishab,

    Did you find a workaround? how did you get around thsi issue?

    Thanks
  10. Viktor Tsvetkov
    Admin
    Viktor Tsvetkov avatar
    382 posts

    Posted 24 Jul 2012 Link to this post

    Hello Deepak,

    This issue is not resolved and unfortunately there is no workaround, so currently you shouldn't use ItemTemplateSelector for the items in a contextual tab's RadRibbonGroup.

    Greetings,
    Viktor Tsvetkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  11. Deepak
    Deepak avatar
    4 posts
    Member since:
    Jul 2012

    Posted 25 Jul 2012 Link to this post

    Victor ,

    Can you provide a sample application that shows how to add Groups and Buttons to a Contextual Tab (Defined in a ViewModel ) without using ItemTemplateSelector?

    I did  code the buttons right into my XAML without using the ViewModel but this breaks my UI design guidelines.

    Thanks,
    Deepak
  12. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 27 Jul 2012 Link to this post

    Hi Deepak,

    As the ItemTemplateSelector property doesn't work, you can implement a workaround approach. You can define an ItemTemplate for the RibbonGroups' Content. Then you can create a ContentPresenter to display the content of the groups and use binding through a converter to choose the appropriate DataTemplate based on teh type of data:

    <DataTemplate x:Key="GroupContentTemplate">
        <ContentPresenter Content="{Binding}" ContentTemplate="{Binding Converter={StaticResource MyConverter}}" />
    </DataTemplate>
     
    <telerik:HierarchicalDataTemplate x:Name="GroupHeaderTemplate"
          ItemsSource="{Binding Buttons}"
          ItemTemplate="{StaticResource GroupContentTemplate}">
        <TextBlock Text="{Binding Text}" />
    </telerik:HierarchicalDataTemplate>
    and the TemplateConverter implementation looks like that:
    public class TemplateConverter : IValueConverter
    {
        public DataTemplate Button { get; set; }
        public DataTemplate SplitButton { get; set; }
        public DataTemplate ButtonsGroup { get; set; }
        public DataTemplate SmallButtonGroup { get; set; }
     
        #region IValueConverter Members
     
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is SplitButtonViewModel)
            {
                return SplitButton;
            }
            else if (value is ButtonGroupViewModel)
            {
                return ((ButtonGroupViewModel)value).IsSmallGroup ? SmallButtonGroup : ButtonsGroup;
            }
            else
            {
                return Button;
            }
        }
     
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
     
        #endregion
    }

    I attached a sample solution demonstrating this approach. Let meknow if it helps.

    All the best,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner