Xamarin - 如何动态更改图像源?

Xamarin - how to change image source dynamically?

我正在学习本教程并且工作正常。 https://developer.xamarin.com/recipes/android/controls/imageview/display_an_image

但就我而言,我有 200 张图片。用户在EditText中写字,点击按钮后,分别显示图片。 如何更改以下代码中的图片源:

 EditText edit = FindViewById<EditText>(Resource.Id.edtName);

   button.Click += delegate 
        {
            img.SetImageResource(Resource.Drawable.sample2);

        }; 

其中 "sample2" 更改为 edit.Text。 (为用户写的文字...)

使用方法更改可绘制对象

    public void changePhoto()
    {
        int MyPhoto;
        if (edit.Text != string.Empty)
        {
            try
            {
                MyPhoto = (int)typeof(Resource.Drawable).GetField(edit.Text).GetValue(null);
            }
            catch
            {
                MyPhoto = Resource.Drawable.ErrorPhoto;
            }
            img.SetImageResource(MyPhoto);
        }
    }
    button.Click += delegate 
    {
        changePhoto();
    };