hi,
is it possible to have a usercontrol in a XamRibbonTabItem or XamRibbonGroup? can you please point to some sample code on this?
thanks.
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?
Hello,
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.
Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
if we need to have multiple user controls in different ribbon tab items, is it possible to create a generic class that inherits ribbontool type for all the user controls or do we need to create different content templates for each of the usercontrol?
Also, in the above provided sample, on changing ribbontabitem(if there is more than one),it throws following exception
"Provide value on ‘System.Windows.Data.Binding’ threw an exception"
thank you.
if we need to have multiple user controls in different ribbon tab items, is it possible to create a generic class that extends ribbontool type for all the user controls or do we need to create different content templates for each of the usercontrol?
I have been looking into your reply and I have modified the sample application in order to demonstrates how you can access the UserControl through the XamRibbon and the XamRibbon through the UserControl. To do that I have added a property to the UserControlRibbonTool form type RibbonToolUserControl and initialize it. In the Template for the UserControlRibboToolControl, I have changed the UserControlRibboToolControl with a ContentControl and bound its Content to the property form type UserControlRibboToolControl that I have added to the custom tool. By doing so you can access the UserControl through the custom tool and the XamRibbon. Also I have bound the Tag property of the ContentControl that holds the RibbonToolUserControl, to the UserControlRibboToolControl’s Tool.Ribbon property and by doing so you can access the XamRibbon in the user control.