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:
CodeSystem.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>
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