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