'System.Reflection.TargetInvocationException' occurred in PresentationFramework.dll

后端 未结 5 738
时光取名叫无心
时光取名叫无心 2021-02-03 21:03

Okay, I have a bit of a weird bug...

This works fine:

private void radioButtonNormalPoint_Checked(object sender, RoutedEventArgs e)
{
   //comboBoxNormal         


        
5条回答
  •  名媛妹妹
    2021-02-03 21:22

    This is often caused by an attempt to process a null object. An example, trying to empty a Bindable list that is null will trigger the exception:

    public class MyViewModel {
        [BindableProperty]
        public virtual IList ProductsList{ get; set; }
    
        public MyViewModel ()
        {
            ProductsList.Clear(); // here is the problem
        }
    }
    

    This could easily be fixed by checking for null:

    if (ProductsList!= null) ProductsList.Clear();
    

提交回复
热议问题