Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 58056 articles
Browse latest View live

PropertyChanged not executed while triggered from listview

$
0
0

Hi, i hope someone could answere/help me. I've created a View which displays a button and a label. Also a Listview is beneth those two elements on the view.
The labeltext and the listview shows userdate which gets from databinding of a viewmodel. A addet on every list-entry also a button, which does directly the same Icommand like the button which is directly above the listview. The Icommand sets a string (username) into the device credentials (Xam.Plugins.Settings) and also does a OnPropertyChanged which updates the labeltext on the view.

It works 100% perfectly while using this one button directly on the view, but the buttons in the listview just ignore the Propertychange. The other code in the Icommand is also executed - i am just talking about the process of updating this labeltext with propertychange.

anyone 've an idea?

View.XAML

<StackLayout Padding="30,20,30,0">
// ******This is the Button which can do the Propertychange!
 <Image x:Name="test" Source="icologin_50.png" VerticalOptions="Start" HorizontalOptions="Start">
                <Image.GestureRecognizers>
                    <TapGestureRecognizer  Command="{Binding TapCommand}"  CommandParameter="manu" />
                </Image.GestureRecognizers>
            </Image>
//******This is the Label, which i want to be updated with propertychange

            <Label x:Name="LabelChange" x:FieldModifier="Public" Text="{Binding UserWhichIsLoggedIn}" VerticalOptions="Start" HorizontalOptions="CenterAndExpand" TextColor="White" FontSize="50"   />


// ******This is the Lisview
                  <ListView  x:Name="Userlist"  Margin="20" RowHeight="60" BackgroundColor="White">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <StackLayout Padding="20,0,20,0" Orientation="Horizontal" >
                                <Label Text="{Binding Firstname}" VerticalTextAlignment="Center" FontSize="20" TextColor="#033a63"/>
                                <Label Text="{Binding Lastname}" VerticalTextAlignment="Center" FontSize="20" TextColor="#033a63"/>
                                <Image x:Name="SwitchUserIcon" Source="icologin_50.png"  HorizontalOptions="EndAndExpand">
                                    <Image.GestureRecognizers>
                                        <TapGestureRecognizer 
                                                    Command="{Binding TapCommand}" 
                                                    CommandParameter="{Binding Uid}"/>
                                    </Image.GestureRecognizers>
                                </Image>
                            </StackLayout>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </StackLayout>     

View.XAML.CS

 [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class Userchange : ContentPage
    {
        public Userchange()
        {
            InitializeComponent();
            BindingContext = new UserSimpleViewModel();
        }

        protected override void OnAppearing()
        {
            base.OnAppearing();
            Device.BeginInvokeOnMainThread(async () =>
                {
                    UserSimpleViewModel Client_UserSimpleViewModel = new UserSimpleViewModel();
                    Infotext.IsVisible = true;
                    Userlist.ItemsSource = await Client_UserSimpleViewModel.Userlisteladen();
                });
        }
}

ViewModel

 public class UserSimpleViewModel : INotifyPropertyChanged
    {

        UserSimple Model_UserSimple = new UserSimple();
        RestClient client_RestClient = new RestClient();    
        LoginEngine client_LoginEngine = new LoginEngine(); 
        ICommand tapCommand;

        public string Firstname { get; set; }
        public string Lastname { get; set; }
        public int Uid { get; set; }

        public UserSimpleViewModel()
        {
                        tapCommand = new Command(OnTapped);
        }

        public string UserWhichIsLoggedIn
        {
            set
            {
                Model_UserSimple._userwhichisloggedin = Bonisda.Helpers.Settings.LoginUsername;
            }
            get
            {
                Model_UserSimple._userwhichisloggedin = Bonisda.Helpers.Settings.LoginUsername;
                return Model_UserSimple._userwhichisloggedin;
            }
        }

        public ICommand TapCommand
        {
            get { return tapCommand; }
        }

        public async Task<List<UserSimpleViewModel>> Userlisteladen()
        {
            return await client_RestClient.GetAllUserSimple("URL");
        }


        public void OnTapped(object s)
        {
              string entered_password = null;
            entered_password = s.ToString();

            Bonisda.Helpers.Settings.LoginUsername = entered_password;
            Model_UserSimple._userwhichisloggedin = Bonisda.Helpers.Settings.LoginUsername;
            OnPropertyChanged("UserWhichIsLoggedIn");
            //PropertyChanged(this, new PropertyChangedEventArgs("UserWhichIsLoggedIn")); // its also not working with this one
           }



        #region INotifyPropertyChanged 
        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
        #endregion

    }

Splash screen xamarin forms ios does not display anymore VS 2017 15.5.2

$
0
0

The splash screen in my xamarin forms ios app is not displaying anymore. I believe this started happening after I updated to VS 2107 15.5.2

Is there a workaround for this?

thanks!

WCF Web Service not create begin/end Method

$
0
0

I created a new Cross Plataform with .net Standard project. I am using VS 15.5.2

I need to add the proxy to access my web service in the .net stardard project.

After adding, I noticed that the begin / end methods were not created. Async-terminated methods have been created.

I tried to consume the method as follows:

ServiceReference1.WcfServiceClient client = new ServiceReference1.WcfServiceClient();

var echo = await client.EchoAsync("Hello World!");

It did not work, VS returns the following error:

Mono does not support dynamic proxy code generation

How can I then generate the proxy correctly for Xamarin projects that use the .net standard in place of PCL?

How to determine iOS version number in Xamarin?

$
0
0

How to determine iOS version number in Xamarin?
Who knows, please tell me, thank you!

App crashing in android mobile

$
0
0

Can any one help me on this the app is already made it s working fine in some mobiles(Android-7 and Api level 24), But its not working fine in samsung s5 (Android-7 and Api level 24)android mobile. May i know the reason am getting the app crashed?

Thanks in advance.

app crash in device and not in simulator

$
0
0

Can anyone Please help me on this My app is running on the simulator is working fine but not in device keep on getting the crashes. May I know what is the issue am facing with?? Please help me.

Thanks.

Load more items without button click

$
0
0

Dears,

I am implementing load more items to listview without a button.

My code:

 public partial class DashBoardPage : ContentPage
  {
    ObservableCollection<string> Items;
    bool isLoading;

    public DashBoardPage()
    {
        InitializeComponent();

        Items = new ObservableCollection<string>();
        var listview = new ListView();

        listview.ItemsSource = Items;
        listview.ItemAppearing += (sender, e) =>
        {
            if (isLoading || Items.Count == 0)
                return;

            //hit bottom!
            if (e.Item.ToString() == Items[Items.Count - 1])
            {
                LoadItems();
            }
        };
        LoadItems();
    }

    public async void LoadItems()
    {
        isLoading = true;
        HttpClient client = new HttpClient();
        var response = await client.GetAsync("My Url");
        string tweetJson = await response.Content.ReadAsStringAsync();

        UserTweetResponse userTweetResponse = new UserTweetResponse();
        if (tweetJson != "")
        {
            userTweetResponse = JsonConvert.DeserializeObject<UserTweetResponse>(tweetJson.ToString());
        }
        ListView1.ItemsSource = userTweetResponse.userTweetsList;
        isLoading = false;
    }
}

I refer the following link and confused with the for loop inside LoadItems():
https://montemagno.com/load-more-items-at-end-of-listview-in/
for (int i = 0; i < 20; i++)
{
Items.Add (string.Format("Item {0}", Items.Count));
}
In my case I am using itemSource property to bind the response to list view.
How can I fix this?
Thanks in advance :)

Metadata dll could not found.

$
0
0

Unable to debug the solution.please help me out


DatePicker Translation

$
0
0

Hi,

In my app, we are managing different languages that are independent from the device language.
In a simple page, we have a DatePicker control and we want it to be translated in a specific language (user's choice).
The problem is not concerning the date format of the entry but actually the texts in the dialog like the month or the day.

I've tried some tricks setting CurrentCulture, CurrentUICulture or ThreadCulture but it doesn't seem to work.
For instance, my device is in english but my app is in french and the DatePicker is still showing the date like 'Sat 4 May' .

Is there any solution for this ?

Thanks,
Fabien.

MasterDetailsPage Menu Icon not showing up on iOS

$
0
0

Hi all,

I have an app with a MasterDetailsPage that I use for the main navigation. I am using the "hamburger" icon for my menu icon. On Android this works great. I set the Icon property on the MenuPage which is a ContentPage. And the "hamburger" appears. But on iOS nothing shows up no matter what I do. Anyone have any advice on what might be wrong or how to fix this?

Click on map overlay

$
0
0

Hi,

I am looking to create a Xamarin Forms app where i have to show the map and draw some circle overlays to it. I'm able to draw the circles using the samples provided by Xamarin. However I am not sure how can I raise a click event when user clicks on the circle. On click of a circle I need to open up a popover window to display some information.

I am new to Xamarin and not sure how can I can do that. Any help?

Images not always showing

$
0
0

I'm making a game and I've noticed that images do not always display its imagesource. This seems to happen more frequently. I have all images set as Embedded with copy if newer in my project. My project now contains **578 **embedded images. I'm always using the normal Image component.

I get the images with this code:

    public static ImageSource GetImage(Images name, ImageType imgType)
            {
                string key = "PartyTime.Resources." + imgType.ToString() + "." + name + ".png";

                try
                {
                    if (m_Images.ContainsKey(key)) return m_Images[key];

                    ImageSource img = ImageSource.FromResource(key);

                    m_Images.Add(key, img);

                    return img;
                }
                catch (Exception ex)
                {
                    Classes.Globals.Log("GetImage(2) Ex: " + ex.ToString());
                    return ImageSource.FromResource(key);
                }
            }

I cant post images yet with this new account so I'll try to explain it with symbols below. Consider each [tile] as an image. Sometimes an image does not show the image assingned to the imagesource:
[tile][tile][tile][ ][tile]

Any suggestions would be greatly appreciated.

How to make the dynamic grid view and make it clickable?

$
0
0

Is there a way to dynamically create a grid's from the List and make it clickable on the PCL project using mvvm?

Problem when i try to install Plugin.Firebase.PushNotification

$
0
0

I get started a new Project from scratch. When i went try to install the plugin(Firebase.PushNotification) i was not getting to install in the Android Project. The error is: You are trying to install a package which is designed to MonoAndroid only Version=v7.1. I uninstalled all package and i went installing one by one. PCL and IOS, is ok, but android not. Why?

how to save multiple Entry.text or Label.Text for reassign to an other Entry.Text

$
0
0

Hi all,
habitually for this step i use in C# two List<> and a double loop.

I add Label.Text in a List:

List mytext = new List();
mytext.Add(Label.Text);

I group my Controls in a List:

List myEntry = new List();
myEntry.Add(Entry);

And i reassign a string with double loop:

foreach (var S in myEntry)
{
foreach (var e in mytext)
{
S.Text = e
}
}

but it does not work in Xamarin.Forms
I create dynamiclly the Entry, i save a TextValue for each Entry, I modify a number of Entry and i reinject a Value.Text.

Can you helpme please ?

Thx


"hit area" to image gesture recognizer not accurate

$
0
0

I have a strange behavior of tap gesture to an Image. A tap work, no problem.

But the "hit area" overflow to image and include a Parent....

I test in a grid or stacklayout, or frame, with widthrequest for a large native image or resize in photoshop my image to make it smaller... without success.

Curiously on some page hit area is correct, and other page include Parent...

Have you ever had this behavior ?

ps: i work in abolutelayout, format image is PNG, not test for the moment inputTransparent to the parent

Listview inappropriate behavior

$
0
0

Hi have 2 Entry in my Listview and 1 image clickable.

-click Image => clear row Listview (no problem).

-filling the first Entry and unfocus => create new row listview (no problem).

-filling the first Entry and unfocus(create new row listview), then filling second Entry and unfocus ==> if i focus second row and add just one char, the Entry unfocus automaticly and create new row list view ?????

After 3 days... i don't understand this behavior

`
<ListView SeparatorVisibility="None" HasUnevenRows="True" x:Name="listevisible" ItemsSource="{Binding ChirurgieList}">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <local:Chirurgie>
                            <StackLayout x:Name="{Binding IdEntry}">

                                <StackLayout Orientation="Horizontal">

                                    <Frame BackgroundColor="{StaticResource Leviolet}" Padding="2" HasShadow="False" HorizontalOptions="FillAndExpand" InputTransparent="True">
                                        <Entry  Text="{Binding Chir}"
                                                x:Name="{Binding IdEntry}"
                                                ClassId="{Binding IdEntry}"
                                                Keyboard="Text"                                                   
                                                Placeholder="(vide)"                           
                                                Style="{StaticResource Poursaisi}"                           
                                                FontSize="Medium"                           
                                                BackgroundColor="#f1f0f0"                           
                                                HorizontalTextAlignment="Start"                                                                                                        

                                                Focused="Entry_Focusedchir"
                                                Unfocused="Saisichir_Unfocused"/>
                                    </Frame>

                                    <Frame BackgroundColor="{StaticResource Leviolet}" Padding="2" HasShadow="False" WidthRequest="60" >
                                        <Entry  Text="{Binding Annee}"
                                                x:Name="{Binding Iddate}"
                                                ClassId="{Binding Iddate}"
                                                Keyboard="Numeric"                                                   
                                                Placeholder="(vide)"                           
                                                Style="{StaticResource Poursaisi}"                           
                                                FontSize="Medium"                           
                                                BackgroundColor="#f1f0f0"                           
                                                HorizontalTextAlignment="Center"
                                                />
                                    </Frame>



                                    <StackLayout ClassId="{Binding IdEntry}" 
                                                 Orientation="Horizontal" 
                                                 HorizontalOptions="End" 
                                                 WidthRequest="27" >
                                        <Image Source="{StaticResource effacement}" WidthRequest="20"/>
                                        <Image.GestureRecognizers>
                                            <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
                                        </Image.GestureRecognizers>
                                        <Image/>
                                    </StackLayout>
                                </StackLayout>

                                <BoxView HeightRequest="5"/>
                            </StackLayout>
                        </local:Chirurgie>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
`

and my Cs page

`
public partial class Page6 : ContentPage
{
    public Dictionary<int, Entry> GroupEntry { get; set; }
    public ObservableCollection<Chirurgie> ChirurgieList = new ObservableCollection<Chirurgie>();

    public string AVsaisi;
    public string AVdate;
    public int compteur = 0;

    public Page6()
    {
        InitializeComponent();

        foreach (var s in (Array)Application.Current.Resources["AtcdChir"])
        { listevisible.ItemsSource = CreateItems(((Chirurgie)s).Chir, ((Chirurgie)s).Annee);}           
    }


    //################### FOCUS ENTRY #######################
    private void Entry_Focusedchir(object sender, FocusEventArgs e)
    {
        AVsaisi = ((Entry)sender).Text;            
    }


    //################### UNFOCUS ENTRY #######################
    private void Saisichir_Unfocused(object sender, FocusEventArgs e)
    {

        // zone de texte est vide on ne fait rien
        if (string.IsNullOrWhiteSpace(((Entry)sender).Text))
        {
            //si le conteneur etait plein auparavant on efface le conteneur
            if (!string.IsNullOrWhiteSpace(AVsaisi))
            {
                int test = 25;
                foreach (var item in ChirurgieList)
                {
                    // Si l'ID de l'entrer est egale a la valeur d'un IdEntry présent dans la liste des maladie on le supprime 
                    if (((Entry)sender).ClassId == item.IdEntry.ToString())
                    {
                        //numero ID a effacer
                        //test = item.IdEntry;
                        // il faut retrouver l'index ce cette idée unique
                        test = ChirurgieList.IndexOf(item);
                    }
                }
                ChirurgieList.RemoveAt(test);
            }

            //si il etait déja vide on ne fait rien
            else
            { }
        }

        //si zone de texte remplie 
        else
        {
            //mais déja remplis au focus (donc deja eu creation d'un conteneur)
            if (!string.IsNullOrWhiteSpace(AVsaisi))
            { }

            // le champs a été remplis  on ajoute un nouveau conteneur vide
            else
            {
                listevisible.ItemsSource = CreateItems(string.Empty, string.Empty);

            }
        }           
    }



    //################### CLIC BOUTON EFFACEMENT #######################
    private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
    {
        int indexaEffacer=20000;
        bool remplissage = false;

        // on obtient l'ID de l'image grâce au ClassId du stacklayout conteneur
        string LAid = ((StackLayout)sender).ClassId;

        //on passe en revue chaque item (les stacklayout conteneur) 
        foreach (var item in ChirurgieList)
        {
            // Dans chaque item on va chercher la valeur de idEntry et on la compare a la valeur de "ClassId" du conteneur de l'image
            if (LAid == item.IdEntry.ToString())
            {
                // dans cet item on va chercher la valeur de "Chir"
                if (string.IsNullOrWhiteSpace(item.Chir))
                {
                    // elle est vide on ne fait rien                       
                }

                // la valur chir n'est pas vide 
                else
                {
                    //on efface cette item c'est a dire tous le stacklayout.
                    //on recupere l'index de cette item
                    indexaEffacer = ChirurgieList.IndexOf(item);
                    remplissage = true;                        
                }
            }
        }
        // seulement si champs remplis
        if (remplissage)
        { ChirurgieList.RemoveAt(indexaEffacer); }
    }


    public ObservableCollection<Chirurgie> CreateItems(string lachir, string lanee)
    {
        var items = ChirurgieList;
        var uniqueID = compteur;

        ChirurgieList.Add(new Chirurgie() {IdEntry = uniqueID, Chir = lachir, Iddate = "A" + uniqueID, Annee = lanee });

        compteur++;
        return items;
    }
}
`

And class

` public class Chirurgie : ViewCell
 {
     public string Chir { get; set; }
     public int IdEntry { get; set; }
    public string Iddate { get; set; }
    public string Annee { get; set; }
 }`

I think there is a confusion of the two entry but....

thx for your help

java.lang.NullException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isMutable

$
0
0

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isMutable()' on a null object reference
at android.graphics.Canvas.(Canvas.java:149)
at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewAdapter.n_getView(Native Method)
at md5b60ffeb829f638581ab2bb9b1a7f4f3f.ListViewAdapter.getView(ListViewAdapter.java:100)

Got a SIGABRT while executing native code

$
0
0

Hi,

When I add ViewCell to listview control, IOS app crashes, when I remove the ViewCell and leave the textcell, all works perfectly. What am I missing here?
Here is my code:


<ListView.ItemTemplate>


<ViewCell.ContextActions>

</ViewCell.ContextActions>

                            </ViewCell>

                    </DataTemplate>

                </ListView.ItemTemplate> 
            </ListView> 

Thank you for your advice.

Kamal

Convert Image Source to Base64

Viewing all 58056 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>