Код: Выделить всё
Код: Выделить всё
public NameMatchViewModel() {
ImageItemTappedCommand = new Command((obj) = >{
try {
//reset the bg color
foreach(var item in ImageItems) {
item.ImageBGColor = Colors.White;
}
NameMatchList imageList = obj as NameMatchList;
if (imageList != null) {
Debug.WriteLine("**not null**");
}
else {
Debug.WriteLine("**null**");
}
int index = ImageItems.IndexOf(imageList);
imageList.ImageBGColor = Color.FromArgb("#0091da");
//Storing name and imageurl to local db
if (Utility.IsInternet()) {
Preferences.Default.Set("NameMatchImageList_Image", imageList.imageUrl);
}
else {
Preferences.Default.Set("NameMatchImageList_Image", imageList.FullImageUrl);
}
Preferences.Default.Set("NameMatchImageList_Name", imageList.name);
Preferences.Default.Set("ImageItem", imageList);
isImageSelected = true;
if (isImageSelected && isNameSelected) {
//If both image and name selected by player startes checking the matching
StartNameMatchCheck(imageList);
}
}
catch(Exception imagetapEx) {
Debug.WriteLine("imagetapEx:>>" + imagetapEx);
}
});
}
Исключение касается строки ниже:
Код: Выделить всё
imageList.ImageBGColor = Color.FromArgb("#0091da");
Код: Выделить всё
**null**
12:30:36:070 [0:] imagetapEx:>>System.NullReferenceException: Object reference not set to an instance of an object.
12:30:36:070 at MyProjectName.Model.NameMatchViewModel.b__98_0(Object obj) in E:\My Projects\MAUI\MyProjectName-app-maui\MyProjectName\Model\NameMatchViewModel.cs:line 390
Подробнее здесь: https://stackoverflow.com/questions/793 ... gedcommand