question

Ashwini-0407 avatar image
0 Votes"
Ashwini-0407 asked alessandrocaliaro commented

Language dropdown with Flag in Xamarin forms

Hi ,

I working on Xamarin forms application, I want to implement Language dropdown with Flags , as given in Example below. I need to implement both in android and iOS.

Please help me with this.


97078-7271473c-82cb-430c-a60e-3b144aa4668c.png97175-7ea23598-908c-427e-997d-bfb6e083d1e1.png


dotnet-xamarin
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Show or hide a Listview when clicking on the tab item,and set the image on the tab(Button) according to the selected item.

0 Votes 0 ·
alessandrocaliaro avatar image
0 Votes"
alessandrocaliaro answered

I think you can create a popup with a collection view

for the popup you can use Xamarin-Community-Toolkit-Platform-Perfect-Popups-Part-1


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Ashwini-0407 avatar image
0 Votes"
Ashwini-0407 answered alessandrocaliaro commented

Hi @alessandrocaliaro Thanks for the idea, I was able to implement the same way as you suggested.
But i am not able to bind the image from view model.
Scenario: I have 3 flag images. when i select the country images has to bind with respective flags. Thats not happening in my code.

Xaml

<Image x:Name="image" WidthRequest="25" Source="{Binding SomeImage}" HeightRequest="25" Margin="0,0,20,0">
<Image.GestureRecognizers>
<TapGestureRecognizer Command="{Binding OpenLanguage}"/>
</Image.GestureRecognizers>
</Image


viewModel:
private ImageSource _someImage;
public ImageSource SomeImage
{

         get { return _someImage; }
         set
         {
             _someImage = value;
             OnPropertyChanged("SomeImage");
             // better yet
             // OnPropertyChanged(nameof(ImageBattery));
         }
     }

method:

if (selected_Item.Key.ToString() == "zh")
{
SomeImage = ImageSource.FromFile("china_Flag.png");

          }
          else if (selected_Item.Key.ToString() == "en")
          {
              SomeImage = ImageSource.FromFile("UK_image.png");
          }
          else if (selected_Item.Key.ToString() == "pt")
          {
              SomeImage = ImageSource.FromFile("pt_Flag.png");
          }






· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I don't know.

You can take a look to this: watch


0 Votes 0 ·