I'm trying to do some calculations according to what is selected in the comboboxes but I keep getting System.NullReferenceException: 'Object reference not set to an instance of an object.' as an error.
This is my code, the error appears in the line with the if statement:
private void TokenWorthtxtBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (BookCondition.SelectedItem == null || BookGenre.SelectedItem == null || BookFormat.SelectedItem == null || BookExamBoard.SelectedItem == null)//this is where the error appears
{
errormessage.Text = "Please select values from the drop down boxes.";
}
else
{
int tokenPrice = BookPriceCalculation(BookTitleTxtBox.Text, BookCondition.SelectedItem.ToString(), BookGenre.SelectedItem.ToString(), BookFormat.SelectedItem.ToString(), BookExamBoard.SelectedItem.ToString());
DisplaySuggestedTokentxtBlock.Text = $"Suggested Token: {tokenPrice}";
}
}