Ticket T1284324
Visible to All Users

Why is my binding failing? documents and charts

created 4 days ago

I'm having a hard to diagnose issue.

I am creating multiple report tabs. Every time i clcik run, i add a new tab to a document, and then generate a devexpress chart.

Here's how I'm generating the control. This all works fine WHEN THERES NO OTHER TABS. Where's other tabs open, the Legend title will fail to bind, and this is the binding error:

Code
System.Windows.Data Error: 3 : UpdateCannot find element that provides DataContext. BindingExpression:Path=DataContext; DataItem=null; target element is 'LegendTitle' (Name=''); target property is 'DataContext' (type 'Object')

What's bizarrre is that the content of my report is correct. The bars show up, the legend items are correct. It's just the legend title. If i close all tabs, and regenerate the report, it's fine. As long as there's no tabs open, it's correct. Otherwise, it's alwasy broken

C#
var viewModel = new TopNRejectedTestPointsViewModel(); var doc = _documentManagerService.CreateDocument( typeof(TopNRejectedTestPointsViewModel).FullName, viewModel); doc.Id = _documentManagerService.Documents.Count(); doc.DestroyOnClose = true; doc.Title = Resources.top_n_rejected_test_points; var testPoints = await Model.GetReportDataTopNRejectedTestPointsAsync(cancellationToken); viewModel.Receive( new RequestReportTopNRejectedTestPointsMessage( this, testResults, testPoints, CurrentBreakdownType ?? BreakdownTypes.None)); doc.Show(); break;

View model definiton (MVVM Community Toolkit)

C#
[ObservableProperty] private string _breakdownType = "";

View

XAML
<dxc:ChartControl CrosshairEnabled="False"> <dxc:ChartControl.Titles> <dxc:Title HorizontalAlignment="Center" Content="{x:Static properties:Resources.top_n_reject_title}" /> </dxc:ChartControl.Titles> <dxc:ChartControl.Legends> <dxc:Legend> <dxc:Legend.Title> <!--<dxc:LegendTitle Content="Breakdown" />--> <dxc:LegendTitle Content="{Binding BreakdownType}" /> </dxc:Legend.Title> </dxc:Legend>
Comments (1)
SC SC
Steven Castro (DevExpress Support) 3 days ago

    Hello Greg,

    The message hints an issue with the data context, which indicates that it may not have been inherited correctly. However, I will need additional information to give any specific recommendations. Please share a simplified project that replicates the issue (A request for simple example programs). This would help me analyze the issue more effectively and recommend an appropriate solution.

    Regards,
    Steven

    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.