Search code examples
c#xamarinxamarin.iosxamarin-zebblezebble

How can I pick the photo from the device in Zebble for Xamarin?


I want to get the picture from the user in my application and for this reason, I use file picker which exists in Zebble UI components like this code:

In my page:

<FilePicker Id="MyFilePicker"></FilePicker>

I did find the code from this link http://zebble.net/docs/filepicker-class But, I had a problem with this component, because I just want to pick some pictures from the device, not video or anything else.


Solution

  • As you mentioned in your question I review the website and find this code, after that I tested it on my android device and I figure out this is the answer.

    First, add this code to your page to show the file picker user interface

      <z-place inside="Body">
    
        <FilePicker Id="MyFilePicker"></FilePicker>
    
      </z-place>
    

    Then, add below code to the page code behind to set the control just for picking the photos.

     public override async Task OnInitializing()
     {
            await base.OnInitializing();
            await InitializeComponents();
    
            MyFilePicker.Set(x => x.AllowOnly(MediaSource.PickPhoto, 
           MediaSource.TakePhoto));
     }