Unexpected red border (validation error) on DataGrid when selecting blank row

前端 未结 5 871
旧时难觅i
旧时难觅i 2020-12-31 00:44

When I select (by clicking or by keyboard) blank row on my DataGrid (when I want to add new row), unexpected validation error occurs (but with no exception) - the border of

5条回答
  •  借酒劲吻你
    2020-12-31 01:36

    To get the reason, when you click the new row of DataGrid in Debug mode, please see the debug window. There are first exception messages which will give you the idea why your problem is occurred.

    Yes, the problem is from type casting. You need to modify the type of SelectedItem to object type as below.

    public class ManageModulesVM : BaseVM  // Implements INotifyPropertyChanged
    {
        // ...
    
        public object SelectedConfigFile
        {
            get { return selectedModule == null ? null : selectedModule.SelectedConfigFile; }
            set
            {
                if (value != null)
                {
                    selectedModule.SelectedConfigFile = value;
                }
                OnPropertyChanged(() => SelectedConfigFile);
                OnPropertyChanged(() => Parameters);
            }
        }
    
        // ...
    }
    

提交回复
热议问题