hi,
is it possible to have a usercontrol in a XamRibbonTabItem or XamRibbonGroup? can you please point to some sample code on this?
thanks.
Hello,
Thank you for your post. I have been investigating the functionality that you are looking for and I can suggest creating a custom tool and add it in a RibbonGroup. You can add the user control that you wish to display in the template for that custom tool. I have created a sample application for you that demonstrates how you can implement this approach.
Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
thank you for the quick reply and the solution works.
how does the interaction between usercontrol and xamribbon work as the user control is now in a controltemplate. is it possible to get the instance of xamribbon in the usercontrol and is it possible to get instance of usercontrol in xamribbon?
Thank you for your reply. I have been looking into the issue that you have described, regarding the exception when having multiple tabs and it seems that it is caused, by the fact that the UserControl property of the custom tool is set as content for the ContentControl and when the tabs are changed the same user control is assigned to new ContentControl, since the RibbonToolControl is reloading and this cause a InvalidOperationException, since the user control is already child of another element. In order to avoid this issue I have overridden the OnApplyTemplate method of the UserControlRibbonToolControl and there I am getting the ContentControl and setting its content to the Tool.UserControl property and also I am handling the Unloaded event and it the event handler I am clearing the content of the ContentControl.
Regarding the first question that you are having, after some research, the best approach I could think of, for implementing generic tool that accepts different UserControl, seems to be following the approach that I have already suggested and changing the UserControl property of the UserControlRibbonTool to type UserControl, instead of the custom type of which the property is currently. By doing so you will be able to use the same tool for every user control that you wish to display in the XamRibbon. I have modified the sample application that I have sent you previously in order to implement the changes that I have mentioned and also added one more tab and user control. The second tab contains the same type of tool (UserControlRibbonTool), but its UserCotnrol property is set to second USerControl that I have added to the Silverlight project.
thank you for the reply. i want to know if it is ok to push usercontrols inside a xamribbon? can the xamribbon have many user controls and will this cause any other issues?
are there any known issues if the xamribbon has usercontrols?
Thank you for your feedback. The XamRibbon control is not designed to be host for controls and UserControls, it is supposed to host RibbonTools in it and this is the reason that I have created the approach that I have provided you, with implementing the custom RibbonTool that allows you to add different UserControl as its visual representation. I have been testing the sample application that I have provided you with and, currently I have found no issues with the implementation. If you are using this approach with many UserControls in the XamRibbon, there should not be any issues.
Please let me know if you need any further assistance while implementing the XamRibbon with UserControls.
I found issue in setting height of control. If my custom control's height is more then it gets hidden partially.. Is there a way to set height of XAM ribbon group in order to display cutom control in full if height of custom control is more?
Hello Tuan and Aneesh,
Thank you for your replies.
Tuan,
I have been looking into the issue that you have described and the reason for the UserContorls to not show in the ChildWindow is that the default style of the custom ribbon tool is defined in the MainPage and the ChildWindow is a popup, which is have different scope and it cannot use the resources of the MaiPage, which results in the custom ribbon tool to have no template. In order to avoid this issue, you can move the default style for the custom tool to the Resources of App.xaml.
Aneesh,
The reason for the user controls to not be fully visible when they have larger height is that the XamRibbon is designed to have specific height and it does not increase its size if there is a content with height more than its. In order to allow the XamRibbon to take more height, you can re-template the XamRibbon and increase the height of the GroupArea Grid, which is part of the Template of the Ribbon. You can get the default style for the XamRibbon from your Infragistics folder. The default path is:
C:\Program Files (x86)\Infragistics\NetAdvantage 2013.1\Silverlight\DefaultStyles\XamRibbon\ generic.xaml
I am also attaching a screenshot of Silverlight Spy, which shows the element that I am referring to.
Krasimir, MCPD
Developer Support Supervisor - XAML