Forum Xamarin Cross Platform with Xamarin

Validate ImageControls


I have a Page with 9 ImageControls, if the user tap on each of them, he can select an image from Gallery or from Take a picture from Camera.

Those ImageControls, has a default image, and when the user select a new image, that image replace the default image.

The User must change the 9 Images to continue to the next Page.

My question is:

How I can validate if the 9 images has been changed?

Please Help...


  • JarvanJarvan Member, Xamarin Team Xamurai

    You can create a parameter and detect the parameter to validate if images have been changed.

    1. Create a paramter 'i'
    2. Get and compare image sources before and after changing
    3. Make the btn enabled accroding to the value of 'i'
    public partial class Page5 : ContentPage
        int i = 1;
        public Page5()
        private void Image_Changed(object sender, EventArgs e)
            string s1 = image.Source.ToString();//get the image source
            //the code of changing image
            //image.Source = "ddarrow.png";
            string s2 = image.Source.ToString();//get the image source after changing
            //compare the two strings
            if (s1 != s2)
                Console.WriteLine("====" + i);
            //while i>9, make the button which's used to navigate to next page Enabled
            if (i > 9)
                btn.IsEnabled = true;
Sign In or Register to comment.