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

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

How to handle click on Map in Xamarin Forms?

$
0
0

I want to click on Map and get that Long/Lat point. How to handle click on Map in Xamarin Forms?
Thank you!

Still no xaml designer?

$
0
0

Just a short question - as I am aware xaml designer was unavailable for forms. Some new releases came since then so I just want to make sure - still no xaml designer?

Defining Font with StaticResource at Xamarin.Form > 2.4

$
0
0

Hi,

I am upgrading my Xamarin.Form from 2.3, but it seems that there are some changes in Font.

I have this in my App.xaml

<OnPlatform x:TypeArguments="Font" x:Key="FontAwesomeBar">
    <OnPlatform.iOS>
        <Font FontFamily="FontAwesome" FontSize="24" />
    </OnPlatform.iOS>
    <OnPlatform.Android>
        <Font FontFamily="FontAwesome" FontSize="28" />
    </OnPlatform.Android>
</OnPlatform>

<Style x:Key="TopBarButtonStyle" TargetType="Button">
    <Setter Property="TextColor" Value="White"/>
    <Setter Property="Font" Value="{StaticResource FontAwesomeBar}"/>
    <Setter Property="BackgroundColor" Value="Transparent"/>
    <Setter Property="WidthRequest" Value="35"/>
    <Setter Property="VerticalOptions" Value="Center"/>
    <Setter Property="HorizontalOptions" Value="Center"/>
</Style>

I received this error message.
"Cannot assign property "FontFamily": Property does not exists, or is not assignable, or mismatching type between value and property"

I looked out their release note, and turned out they changed Font to FontElement
https://github.com/xamarin/Xamarin.Forms/pull/799

But I could not figured out how to solve this. When I tried to change Font to FontElement, I received this error.
"Default constructor not found for type Xamarin.Forms.FontElement"

Anyone had the same problem?

Start with Android System

$
0
0

Does anyone know how to make an android app to start with the android system? This includes running in the background(main activity C# code).
Ive looked everywhere, but nowhere does it say in forums or docs about this(or im not searching correctly probably)


What is the Ideal Apk Size from Xamarin Forms ? And how to reduce it without force close ?

$
0
0

I Have Xamarin Forms App With 10 - 15 Page and when I Archive the Appliaction to get the Apk , it has very big size 72 MB so i search in the internet to get smaller size with linker. So i Activated the SDK Assemblies Only Linker and it reduce like half of the first Apk Size to 32 MB , because i'm not satisfied enough and want to my apk smaller i Activated SDK Linker And User Assemblies and the size got reduced to 22 MB and when i try to run it its always force close And i'm still feel not satisfied enough by the size of my APK . My Target is my Apk size will has 5-15 MB , And how do i Achive that is there 3rd Party tools to do that or is that the ideal size(32 MB) for Xamarin Forms Apk ? because i'm still think that very big size of Apk that only have 10-15 Page

Xamarin + WindowsAzure.MobileServices

$
0
0

Hi all together,
i have a SqlServer table up and running in my Office.

<WorkDate,FK_ProjectNumber,WorkKind,WorkTime> (FK_xx = ForeignKey)

I would like to syncronice these table to Azure and connect to them via MobilePhone and Tablet.

Problems:
a) my mobile devices should only contain entries for running Projects.
b) if a Project is finished, the WorkTime records should be disabled (NOT DELETED) on Azure and on the SQLServer in the Office.
c)CRUD operations shoud be performed on every device.
Is there any best practise or any good advice

Thanks in advance
Peter

Xamarin.Android - The type or namespace name 'App' could not be found

$
0
0

Being creating an app with Xamarin.Forms, it works fine on the Windows platform, however, when I try to run it on my Android phone via the Xamarin Live Player it presents an number of issues, such as the one stated on the title.

I have made no changes to Android files, so I don't know why these errors are appearing. Does anyone know how to solve this issue?

I have also attached the output.

error while referencing sqlite-net-pcl package in xamarin forms andriod project

$
0
0

i am getting the following error when i attempt to reference the sqlite-net-pcl package in the andriod project of xamarin forms project. I get this error when building in release mode but debug mode seems to be fine.
i am using
sqlite-net-pcl 1.4.118
Xamarin.Forms 2.4.0.282
Xamarin.Android.Support.* 25.4.0.2

_Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'SQLite-net, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'SQLite-net.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection1 assemblies, AssemblyDefinition assembly, Boolean topLevel) at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver) CouchPortfolioApp.Android _

Alternative controls for Text (Multiline)

$
0
0

Hi,

What are the good alternatives for the Text controls to use for multiline entry?

Thanks,
Jassim

object of type Ninteroret.InterpretedObject' doesn't match target type 'System.IDisposable'

$
0
0

I'm stuck with below error for past couple of days; I'm trying to test a simple xamarin forms sqlite app using Xamarin Live player on iOS device.
object of type Ninteroret.InterpretedObject' doesn't match target type 'System.IDisposable'(TargetException)

tried in different xamarin forms but did not find solution. did anybody come across this issue and who did you resolve it?

Azure search is not working with typeahead functionality.

$
0
0

Hello guys, I have implemented azure search for searching workspaces from database which I have imported in azure. The issue is when I give a request call for searching the results, it has some time delay into it. My requirement is that I need a flawless azure search without hanging user for every work he types in the Entry field.

private async void SearchEntryTextChanged(object sender, TextChangedEventArgs e)
{
var entry = sender as CustomEntry;
string searchedString = entry.Text;
if (searchedString.Length > 2)
{
_workspaceSearchService = new AzureWorkspaceSearchApi();
List workspaceSearchData = new List();
//workspaceSearchData = await _workspaceSearchService.SearchWorkspaceFromAzure(searchedString);
workspaceSearchData = await _workspaceSearchService.ExecSuggest(searchedString);

               viewModel.SearchWorkspaceRecord = workspaceSearchData;
           }

}

For every character that enter after 2 length I am calling azure search. This request needs some time to get completed and hangs the user until it gets search result. I need these request to be done using typeahead phenomenon. Can anyone suggest me a solution to achieve this?

Below is the azure request:-

public async Task<List> ExecSuggest(string q)
{
try
{
// Execute /suggest API call to Azure Search and parse results
//string url = _serviceUri + AzureSuggestUrl + q;
string url = "https://meelosearchbasic.search.windows.net/indexes/indworkspacesearch/docs/suggest?api-version=2016-09- > >01&suggesterName=sgworkspacesearch&$top=5&$filter=TenantId eq '" + App.userTenantId + "'&search=" + q;
_httpClient = new HttpClient();
Uri uri = new Uri(url);
List Suggestions = new List();

           HttpResponseMessage response = AzureSearchHelper.SendSearchRequest(_httpClient, HttpMethod.Get, uri);
           AzureSearchHelper.EnsureSuccessfulSearchResponse(response);

           var obj = JsonConvert.DeserializeObject<SearchResult>(response.Content.ReadAsStringAsync().Result);
           Suggestions = obj.value;

           return Suggestions.Distinct().OrderBy(x => x.SearchText).ToList();
       }
       catch(Exception e)
       {
           return null;
       }
   }

How to push grid to bottom

$
0
0

Hello, im new to xamarin forms. I've set a grid that acts like a bottom navigation bar. I want to set that this specific grid is allways on bottom. But is not unless I hardcode it. Any ideas?
My code:

       <StackLayout>
            <Grid ColumnSpacing="0" RowSpacing="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="1"/>
                    <RowDefinition Height="44"/>
                </Grid.RowDefinitions>

                <ContentView x:Name="Placeholder" Grid.Row="0" HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand"/>
                <BoxView BackgroundColor="#c6ffd3" Grid.Row="1"/>

                <Grid ColumnSpacing="0" RowSpacing="0" Grid.Row="2" VerticalOptions="End">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <StackLayout Spacing="0" Grid.Column="0" BackgroundColor="AliceBlue">
                        <Image HeightRequest="30" Source="HomeIcon.png"/>
                        <Label Text="Home" FontSize="10" HorizontalOptions="Center"/>
                        <StackLayout.GestureRecognizers>
                            <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
                        </StackLayout.GestureRecognizers>
                    </StackLayout>

                    <StackLayout Spacing="0" Grid.Column="1" BackgroundColor="AliceBlue">
                        <Image HeightRequest="30" Source="HomeIcon.png"/>
                        <Label Text="Home" FontSize="10" HorizontalOptions="Center"/>
                        <StackLayout.GestureRecognizers>
                            <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
                        </StackLayout.GestureRecognizers>
                    </StackLayout>

                    <StackLayout Spacing="0" Grid.Column="2" BackgroundColor="AliceBlue">
                        <Image HeightRequest="30" Source="HomeIcon.png"/>
                        <Label Text="Home" FontSize="10" HorizontalOptions="Center"/>
                        <StackLayout.GestureRecognizers>
                            <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
                        </StackLayout.GestureRecognizers>
                    </StackLayout>

                    <StackLayout Spacing="0" Grid.Column="3" BackgroundColor="AliceBlue">
                        <Image HeightRequest="30" Source="HomeIcon.png"/>
                        <Label Text="Home" FontSize="10" HorizontalOptions="Center"/>
                        <StackLayout.GestureRecognizers>
                            <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
                        </StackLayout.GestureRecognizers>
                    </StackLayout>

                    <StackLayout Spacing="0" Grid.Column="4" BackgroundColor="AliceBlue">
                        <Image HeightRequest="30" Source="HomeIcon.png"/>
                        <Label Text="Home" FontSize="10" HorizontalOptions="Center"/>
                        <StackLayout.GestureRecognizers>
                            <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/>
                        </StackLayout.GestureRecognizers>
                    </StackLayout>

                </Grid>
            </Grid>
        </StackLayout>

Tried with vertical and horizontal options, nothing seems to be working as I would like. Did I placed them wrong?

On iOS Listview header resets after itemsource changes

$
0
0

Hi,

I have a listview with a header template. Header is a horizontal scrollable list, bound to a different source and displays the categories of products, and listview itemsource is bound to another source which displays products. When a user taps on a category, i simply filter the ItemSource and set it to be the new ObservableCollection:

products = new ObservableCollection(allProducts.Where(x=>x.categoryId=selectedCategory.Id)

On android it works perfect: when the category is tapped on the header, listview displays new items, header is "untouched" (eg: if it was scrolled, it stays scrolled).
On iOS, when the category is tapped and the listview ItemSource is reset, then the header refreshes and redraws itself, resetting everything like the scroll position which creates poor user experience.

How can i prevent that on iOS?

Xamarin.froms store app

GoogleMap Marker icon issue in renderer

$
0
0

I'm making renderers in my project, so that the PinType enum will actually have an effect by changing the color of the pins. But whenever I use a non-default icon for the native Marker, it draws as the default icon on top of my icon, with the default disappearing on click.

Here are some screenshots from using marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(BitmapDescriptorFactory.HueGreen)):

image image

And here are some from using marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.ic_launcher)) (my app icon):

image image

And here is my renderer code:

[assembly: ExportRenderer(typeof(ExtendedMap), typeof(ExtendedMapRenderer))]
namespace eLationTechnician.Forms.Droid.Renderers
{
    public class ExtendedMapRenderer : MapRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.View> e)
        {
            base.OnElementChanged(e);

            if(e.NewElement != null)
            {
                UpdatePins();
            }
        }

        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if(e.PropertyName == "Pins")
            {
                UpdatePins();
            }
        }

        private void UpdatePins()
        {
            NativeMap.Clear();

            foreach(var pin in Map.Pins)
            {
                var marker = new MarkerOptions()
                    .SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude))
                    .SetTitle(pin.Label).SetSnippet(pin.Address);

                float hue = 0.0f;
                switch (pin.Type)
                {
                    case PinType.Generic:
                    case PinType.SearchResult:
                    {
                        hue = BitmapDescriptorFactory.HueRed;
                        break;
                    }
                    case PinType.SavedPin:
                    {
                        hue = BitmapDescriptorFactory.HueGreen;
                        break;
                    }
                    case PinType.Place:
                    {
                        hue = BitmapDescriptorFactory.HueBlue;
                        break;
                    }
                }

                marker.SetIcon(BitmapDescriptorFactory.DefaultMarker(hue));

                NativeMap.AddMarker(marker);
            }
        }
    }
}

using Broadcasterreceiver and intent to get incoming call number

$
0
0

Hi,
I tried to use a BroadcasterReceiver to get the incoming call number, of course I need it on the Android version of the app (I think on iOS is not allowed)
I've tried to get the "android.intent.action.ACTION_PHONE_STATE_CHANGED" Intent, and implemented the OnReceive method as follow:

[BroadcastReceiver(Enabled = true)]
[IntentFilter(new[] { "android.intent.action.ACTION_PHONE_STATE_CHANGED" })]
public class IncomingCallReceiver: BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
// ensure there is information
if (intent.Extras != null)
{
// get the incoming call state
string state = intent.GetStringExtra(TelephonyManager.ExtraState);

            // check the current state
            if (state == TelephonyManager.ExtraStateRinging)
            {
                // read the incoming call telephone number...
                string telephone = intent.GetStringExtra(TelephonyManager.ExtraIncomingNumber);
                // check the reade telephone
                if (string.IsNullOrEmpty(telephone))
                {
                    telephone = string.Empty;
                }
                else
                {
                    // Se funziona devo fare chiamata a server per sapere di chi parliamo
                    Toast.MakeText
                    (
                        context,
                             "Stai ricevendo una chiamata da : " + telephone,
                        ToastLength.Long
                    ).Show();
                }
            }
            else if (state == TelephonyManager.ExtraStateOffhook)
            {
                // incoming call answer
            }
            else if (state == TelephonyManager.ExtraStateIdle)
            {
                // incoming call end
            }
        }
    }
}

I need it works on Android version starting from 4.4 till latest one.
Unfortunately it doesn't works on any version. The OnReceive method never starts, the event never fires.
Can anyone help me?
thank you in advance.

Viewing all 58056 articles
Browse latest View live


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