[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.
How to bind datacontext with backstage via element name or relative source to my view model?
Answers approved by DevExpress Support
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.
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?