Bug Report T301032
Visible to All Users

An exception is raised when RibbonGalleryBarItem's name is defined within DataTemplate

created 9 years ago

[DevExpress Support Team: CLONED FROM T213062: Element with the same name already exists in the scope]
In my case, the problem was x:Name attribute on dxr:RibbonGalleryBarItem within a data template.
It is a bit strange because when the "second" item was added the "first" one was supposed to be removed from the ribbon.
<dxr:RibbonPageCategory PagesSource="{Binding Selected.ContextMenu.ChildItems}"> was used and the Selected has changed. ContextMenu was constructed dynamically and different objects that could possibly be assigned to Selected could have an item that would use the same data template. If the explanation doesn't make much sense, I can probably come up with a sample project.
By the way, I'm using 15.1.5 and the name is still not shown in the exception.

Show previous comments (4)
DevExpress Support Team 9 years ago

    Hi Kirill,
    Thank you for the additional clarification. Now I see the exception.
    Would you please clarify the purpose of assigning names to items in the templates. All generated bar items are added to the same namescope, so your current approach will likely cause issues in the future. To reproduce the exception, it's sufficient to add two items to the data source collection.
    I am looking forward to your response.

      Ivan, in the original T213062 Andrey Marten (DevExpress Support) asked how Alexander Muylaert-Gelein solved the issue. And in attempt to be helpful, I added how I solved the same exception in my case.
      In my production code, the idea behind the name was to bind item's command to bar item's command, i.e.
      <dxb:GalleryItem Glyph="{Binding Glyph}" Caption="{Binding Caption}" Command="{Binding DataContext.Command, ElementName=gallery}" />
      Since I know that there will only be one such gallery in the ribbon at any given time, I didn't expect the exception. That's why I called the behaviour "strange". As noted in RibbonItemTemplateSelector.SelectTemplate in my sample project, the fact that the selector is called for a container that is not in any window is a bit strange too.
      Bottom line: I can't even call the behaviour "a bug"; more like "warning to not use names even if you know that they are unique". It would be good if the behaviour is fixed in future versions, but it should not be a showstopper (one can use RelativeSource instead).

      DevExpress Support Team 9 years ago

        Hi Kirill,
        It looks like the behavior in the scenario where only the one named gallery is used in the RibbonControl is incorrect. I have forwarded this ticket to our developers to research. We will contact you once we have any results.

        Thanks,
        Ilya

        Answers approved by DevExpress Support

        created 9 years ago

        We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

        Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.