Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
230
Null-reference exception when using GalleryTool
posted

Hi,

I want to use the GalleryTool at the Ribbon to let the end user choose one item. The items available will be requested via a webservice at program start and will not change until the program is closed. So I am filling the GalleryTool programmatically with Items at the Loaded event.

This works fine in case of the UserControl at which the Ribbon is contained is one of the first controls to be displayed. If it is one later initialized then it might fail to add items programmatically. In my case it fails always, because I am using a tab control to split several application parts and at the last tab the Ribbon is contained and this tab is only callable when the webservice call was successful.

The issue can be easily reproduced when trying to programmatically edit the GalleryTool.Items collection after a button click. Please look at the attachment where I have prepared a Visual Studio Solution.

I need some hints how I can resolve this issue. Any other hint how to put some dynamic content at the ribbon to let the end user choose one of the provided items is also very appreciated.

Thanks.

Regards
Johannes

T_RibbonIssue.zip
Parents
No Data
Reply
  • 6475
    posted

    Hi Johannes,

    Thanks for reporting this issue.This is definitely a bug in the control and we'll strive for fixing it for our next Service Release, which is scheduled for early next week.

    As a "workaround" you could try to add the GalleryItems before the GalleryToolControl is generated, which means before the GalleryTool is rendered for the first time.

    For example, in the scenario that you described:

    jtwspg said:

     In my case it fails always, because I am using a tab control to split several application parts and at the last tab the Ribbon is contained and this tab is only callable when the webservice call was successful.

    If you populate the GalleryTool when the webservice call succeeds and then allow access to the last tab, it should be working fine.

     

    Another workaround would be to delay the creation of the GalleryTool until the items are available. You could create the GalleryTool in code-behind when the list of items comes from the service, add the items to the GalleryTool and then add the GalleryTool to the Ribbon.

     

    Hope this helps,

Children