Ticket T1279727
Visible to All Users

Remove items in a chart can cause a binding exception

created 2 days ago

Clipboard-File-1.png

i modify the sample of [https://github.com/DevExpress-Examples/wpf-charts-create-chart-elements-from-view-model], and add a delete button,
when click , will remove some items in the background like (in chartDemo\CS\ dictionary):

Code
private void itemDelete_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e) { if(DataContext is MainViewModel vm) { vm.Chart.Series.RemoveAt(0); vm.Chart.Panes.RemoveAt(0); vm.Chart.YAxes.RemoveAt(0); vm.Chart.Legends.RemoveAt(0); } }

It does work, but the output prints some binding exception information(as shown below). How can I eliminate these binding exceptions?

System.Windows.Data Error: 40 : BindingExpression path error: 'ShowXAxis' property not found on 'object' ''MainViewModel' (HashCode=13213278)'. BindingExpression:Path=ShowXAxis; DataItem='MainViewModel' (HashCode=13213278); target element is 'ScrollBarOptions' (HashCode=51692872); target property is 'Visible' (type 'Boolean')
System.Windows.Data Error: 40 : BindingExpression path error: 'Title' property not found on 'object' ''MainViewModel' (HashCode=13213278)'. BindingExpression:Path=Title; DataItem='MainViewModel' (HashCode=13213278); target element is 'AxisTitle' (Name=''); target property is 'Content' (type 'Object')
System.Windows.Data Error: 40 : BindingExpression path error: 'ConstantLines' property not found on 'object' ''MainViewModel' (HashCode=13213278)'. BindingExpression:Path=ConstantLines; DataItem='MainViewModel' (HashCode=13213278); target element is 'SecondaryAxisY2D' (Name=''); target property is 'ConstantLineInFrontItemsSource' (type 'IEnumerable')
System.Windows.Data Error: 40 : BindingExpression path error: 'DockTarget' property not found on 'object' ''MainViewModel' (HashCode=13213278)'. BindingExpression:Path=DockTarget; DataItem='MainViewModel' (HashCode=13213278); target element is 'Legend' (Name=''); target property is 'DockTarget' (type 'Object')

Clipboard-File-2.png

Answers approved by DevExpress Support

created 2 days ago

Hello Xu Xin,

Please refer to the following ticket where a similar question is discussed: Binding Error raised when deleting Item from SeriesItemSource DataSource.

I hope this helps.

Regards,
Steven

    Comments (1)

      Hello Steven

      Thanks for your suggestion, I have solved the binding exception.

      Regards,
      Xu Xin

      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.