Ticket T304371
Visible to All Users

How to bind datacontext with backstage via element name or relative source to my view model?

created 9 years ago (modified 9 years ago)

[DevExpress Support Team: CLONED FROM T298740: WPF Report Designer - How to attach a Backstage View to the Ribbon]
HI, I have Implemented the hotfix now, however, I have found that there is no datacontext to the backstage so I am unable to bind via element name or relative source to my view model.

Comments (2)
DevExpress Support Team 9 years ago

    Hello Tom,

    It is difficult to determine the cause of this misbehavior without additional information. Would you please post here a test project so we can replicate this issue on our side? We will investigate it and try to find an appropriate solution.

    Thanks
    Elliot

      Hi, Elliot
      I have reproduced the issue, sorry for the delay.
      The problem is that the ButtonCommand  that i have bound to the backstage item, I am unable to bind to it, I have left in the element name binding to show that it is not working. I have also tried this with relative source to no avail.
      Uponinvestigating the issue I found that there was no datacontext on the backstage.
      With the example given how would I bind the command in the view to the viewmodel?

      Answers approved by DevExpress Support

      created 9 years ago

      Hi Tom,

      There are different ways of binding the Command property in this scenario.

      For example, you can use RelativeSource.AncestorType to obtain the parent ReportDesigner:

      XAML
      <dxr:BackstageButtonItem Command="{Binding Path=DataContext.ButtonCommand, RelativeSource={RelativeSource AncestorType=dxrud:ReportDesigner}}" />

      Another way is to use the attached RibbonControl.Ribbon and ReportDesigner.Designer properties:

      XAML
      <dxr:BackstageButtonItem Command="{Binding Path=(dxr:RibbonControl.Ribbon).(dxrud:ReportDesigner.Designer).DataContext.ButtonCommand, RelativeSource={RelativeSource Self}}" />

      I have attached the modified sample demonstrating both approaches. Please take a moment to review it.

        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.