导管选择器选择的项目 = null Xamarin.forms

Cath picker selected item = null Xamarin.forms

如果用户不会在 picker label 的文本中选择项目,我想变成这样:错误!状态不全!

我试过

        try
        {
            picker.Items[picker.SelectedIndex] = null;
        }

        catch (System.ArgumentNullException)
        {
            Error.IsVisible = true;
            Error.Text = AppResources.ERROR1;
        }

但是不行!请帮我。谢谢!

如果 SelectedIndex 为 -1,则未选择任何项目

if (picker.SelectedIndex < 0) 
{
  Error.IsVisible = true;
  Error.Text = AppResources.ERROR1;
}