Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all 204402 articles
Browse latest View live

CarouselView does not show images

$
0
0

Hi
I have two Models and a ViewModels for articles and posts from DB . One of them like this

and i use BackgroundImage in CarouselView like this

And there is no problem with CarouselView and it shows images . But with another Model that likes this

and use like this

CarouselView does not show anythings . What's the problem ?


Delay in transition screens

$
0
0

Hello community

I set a button in my home, and when I click on in there is a little delay on the transition

Home screen

<StackLayout Padding="30"
                     HorizontalOptions="Center">
            <Image Source="Perfil.png"
                   WidthRequest="50"
                   HeightRequest="50" />

            <Label Text="{Binding Username}"
                   HorizontalOptions="Center" />

            <StackLayout Orientation="Vertical"
                         Spacing="10">

                <StackLayout Orientation="Horizontal"
                             HorizontalOptions="Center"
                             Margin="0,0,40,0">
                    <Button Text="Mis mascotas"
                            ContentLayout="Left,20"
                            Image="Mis_mascotas.png"
                            HorizontalOptions="Start"
                            BackgroundColor="Transparent" />

                </StackLayout>
                <StackLayout Orientation="Horizontal"
                             HorizontalOptions="Center">
                    <Button Text="Agenda de control"
                            ContentLayout="Left,20"
                            Image="Agenda_control.png"
                            HorizontalOptions="Start"
                            BackgroundColor="Transparent" />

                </StackLayout>
                <StackLayout Orientation="Horizontal"
                             HorizontalOptions="Center">
                    <Button Text="Pareja encontrada"
                            ContentLayout="Left,20"
                            Image="Pareja_encontrada.png"
                            HorizontalOptions="Start"
                            BackgroundColor="Transparent" />

                </StackLayout>
                <StackLayout Orientation="Horizontal"
                             HorizontalOptions="Center"
                             Margin="0,0,30,0">
                    <Button Text="Editar mi perfil"
                            Command="{Binding GoToProfile}"
                            ContentLayout="Left,20"
                            Image="Editar.png"
                            HorizontalOptions="Start"
                            BackgroundColor="Transparent" />


                </StackLayout>
            </StackLayout>
            <StackLayout Margin="0,40,0,0"
                         Spacing="20">
                <Image Source="BotonCompra.png" />
                <Button BackgroundColor="{StaticResource ThirdColor}"
                        Text="¿Quieres poner a tu mascota en adopción?"
                        CornerRadius="20"
                        TextColor="{StaticResource BtonsColor}" />
                <Button BackgroundColor="{StaticResource ThirdColor}"
                        Text="¿Quieres poner a tu mascota disponible en busqueda de parejas?"
                        CornerRadius="20"
                        TextColor="{StaticResource BtonsColor}" />
            </StackLayout>
        </StackLayout>
    </ContentPage.Content>
</ContentPage>

HomeVM

     public ICommand GoToProfile { get; set; }
        public List<Item> HamburgersItems { get; set; }
        public HomeViewModel() {

            HamburgersItems = new HamburgerService().GetHamburgerItems();

            GoToProfile = new Command(async () => {
                await Application.Current.MainPage.Navigation.PushAsync(new ProfileScreen());
            });

detail

 <ContentPage Title="Master"
                     Padding="15">
            <StackLayout Orientation="Vertical">
                <StackLayout Orientation="Vertical">
                    <StackLayout Orientation="Horizontal"
                                 HorizontalOptions="FillAndExpand">
                        <Image Source="avatar.png"
                               BackgroundColor="Transparent"
                               HeightRequest="100"
                               WidthRequest="100"
                               VerticalOptions="Center" />
                        <StackLayout Orientation="Vertical">
                            <Label Text="Xamarin"
                                   HorizontalTextAlignment="Start"
                                   FontSize="Large"
                                   Margin="2,0,0,0"
                                   HorizontalOptions="Start"
                                   VerticalOptions="EndAndExpand"
                                   TextColor="Black" />
                            <Label Text="Xamarin Forms"
                                   HorizontalTextAlignment="Start"
                                   FontSize="Small"
                                   Margin="2,0,0,0"
                                   HorizontalOptions="Start"
                                   VerticalOptions="StartAndExpand"
                                   TextColor="#16161d" />
                        </StackLayout>
                    </StackLayout>

                    <StackLayout BackgroundColor="Black"
                                 MinimumHeightRequest="1"
                                 Orientation="Vertical"
                                 HeightRequest="1"
                                 HorizontalOptions="FillAndExpand">
                        <Label Text="fff"
                               FontSize="1"
                               TextColor="Black"
                               BackgroundColor="Black"
                               HorizontalOptions="CenterAndExpand" />
                    </StackLayout>
                    <CollectionView x:Name="MyBurger"
                                    SelectionMode="Single"
                                    ItemsSource="{Binding HamburgersItems}"
                                    SelectedItem="{Binding Item}"
                                    SelectionChangedCommand="{Binding SelectedItemChange}">
                        <CollectionView.ItemTemplate>
                            <DataTemplate>
                                <Grid Margin="10">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="auto" />
                                    </Grid.ColumnDefinitions>
                                    <StackLayout Orientation="Horizontal"
                                                 HorizontalOptions="Center"
                                                 VerticalOptions="Center">
                                        <Image Source="{Binding ImgSource}"
                                               Aspect="AspectFit"
                                               WidthRequest="37"
                                               HeightRequest="37" />
                                        <Label Text="{Binding Title}"
                                               VerticalOptions="Center"
                                               HorizontalOptions="Center"
                                               Grid.Column="1" />
                                    </StackLayout>
                                </Grid>
                            </DataTemplate>
                        </CollectionView.ItemTemplate>
                    </CollectionView>
                </StackLayout>
            </StackLayout>
        </ContentPage>
    </MasterDetailPage.Master>
    <MasterDetailPage.Detail>
        <NavigationPage BarBackgroundColor="{StaticResource PrimaryColor}">
            <x:Arguments>
                <ContentPage Padding="10">
                    <NavigationPage.TitleView>
                        <StackLayout Spacing="30"
                                     Orientation="Horizontal"
                                     VerticalOptions="Center"
                                     HorizontalOptions="Center">
                            <Image Source="LogoTexto.png"
                                   Margin="0,0,50,0"
                                   WidthRequest="200" />
                            <Image Source="CampanaNotificaciones.png">
                            </Image>
                        </StackLayout>
                    </NavigationPage.TitleView>
                    <ContentPage.Content>
                        <ScrollView>
                            <StackLayout>
                                <StackLayout Margin="10,20,0,0"
                                             Orientation="Horizontal">
                                    <ImageButton BackgroundColor="Transparent"
                                                 Source="userPicture.png"
                                           HorizontalOptions="CenterAndExpand"
                                           WidthRequest="182"
                                           HeightRequest="182" />
                                </StackLayout>
                                <StackLayout Margin="10,30,10,0"
                                             Spacing="20">
                                    <Label Text="Nombre del usuario"
                                           HorizontalOptions="CenterAndExpand" />
                                    <Entry Placeholder="Nombre"
                                           Keyboard="Text" />
                                    <Entry Placeholder="Segundo Nombre"
                                           Keyboard="Text" />
                                    <Entry Placeholder="Apellido"
                                           Keyboard="Text" />
                                    <Entry Placeholder="Segundo apellido"
                                           Keyboard="Text" />
                                    <renders:ExtendedDatePicker />
                                    <Picker Title="Genero" />
                                    <Label Text="Ubicación"
                                           Style="{StaticResource SeparatorTextStyle}" />
                                    <Picker Title="Nacionalidad" />
                                    <Entry Placeholder="Documento de identidad"
                                           Keyboard="Numeric" />
                                    <Picker Title="Pais" />
                                    <Picker Title="Estado" />
                                    <Picker Title="Ciudad" />
                                    <Entry Placeholder="Dirección" />
                                    <Label Text="Información de contacto"
                                           Style="{StaticResource SeparatorTextStyle}" />
                                    <Entry Placeholder="Teléfono local"
                                           Keyboard="Telephone" />
                                    <Entry Placeholder="Teléfono Celular"
                                           Keyboard="Telephone" />
                                    <Entry Placeholder="Correo eletrónico"
                                           Keyboard="Email" />
                                    <Entry Placeholder="Correo eletrónico secundario"
                                           Keyboard="Email" />
                                    <Label Text="Acerca de mi"
                                           Style="{StaticResource SeparatorTextStyle}" />
                                    <Editor Placeholder="Una breve descripción"
                                            AutoSize="TextChanges"
                                            Keyboard="Text" />
                                    <Button Text="Guardar"
                                            Margin="0,0,0,20"
                                            Style="{StaticResource YellowButtons}"
                                            HorizontalOptions="Center" />
                                </StackLayout>
                            </StackLayout>
                        </ScrollView>

                    </ContentPage.Content>
                </ContentPage>
            </x:Arguments>
        </NavigationPage>
    </MasterDetailPage.Detail>
</MasterDetailPage>

FontAwesome fonts have disappeared on iOS

$
0
0

I have been using FontAwesome fonts in my app for about a year without any problems. Now, whenever I create a release build of the app, all I get are question marks instead of the icons. If I create a debug build to install on the phone or I run a release build on the simulator everything is fine. I have not changed any of the relevant declaration or definitions.

How can I fix this?

Xamarin Forms: How to create an Epub Viewer in Xamarin Forms?

$
0
0

I am trying to implement an epub viewer in xamarin forms like the below video.

Video Link: https://drive.google.com/file/d/1jW33lstCXqwC35siYklLoXAxItWpQG8c/view?usp=sharing

At first, I need to show the TOC of the book. If taps any chapter in TOC need to show that chapter on the UI. The total chapters and current chapter details are added at the bottom of the page. We can change the font size, font style, light and dark theme, and horizontal and vertical swiping features. Also able to hear the chapter in audio voice. Please have a look at the above video.

This is the native Android implementation. I need to do this feature in xamarin forms, following are my queries.

  1. Is xamarin offer an epub viewer like this? Or I need to do all these features custom?
  2. I tried EpubReader.Cross NuGet package, but it has no TOC list.
  3. How can I change the font size and font style like the video?
  4. For audio voice feature I can use text to speech feature, but when reading the book by voice how can I highlight the text?
  5. There is a package named epubReader, it has a TOC list. But when I try to install it to the project, I am getting this error.

Is it possible re-open app?

$
0
0
Hello guys, I’m developing app now, so user press button and then user’s geolocation pass to the server every set time, so I did it in background through Matcha.BackgroundService library, but I have a problem - when user cross country border there is small offline time and my app stop working maybe cuz of no network connection or waiting for roaming, so how I can re-launch it in iOS and android, I think in android I should use to broadcast service but I don’t know. Maybe it’s not needed to relaunch only keep it in background when no network and when it reveal, continue to pass geolocation
Sorry for my English:)
Thanks all

Strange behaviour, custom notification sound played only in background

$
0
0

Hi

I have a strange problem. I want to play notification sounds when app is active, and when in background too, but now, i dont know why the custom sounds played only when app is in background.

Here is my code

 var content = new UNMutableNotificationContent
            {
                Title = title,
                Subtitle = "",
                Body = message
            };

            if (!string.IsNullOrEmpty(soundFileName))
                content.Sound = UNNotificationSound.GetSound(soundFileName);

            var trigger = UNTimeIntervalNotificationTrigger.CreateTrigger(0.01, false);

            var request = UNNotificationRequest.FromIdentifier(messageId.ToString(), content, trigger);
            UNUserNotificationCenter.Current.AddNotificationRequest(request, err =>
            {
                if (err != null) throw new Exception($"Failed to schedule notification: {err}");
            });

What can i do to play sounds always?

Pass List to another View and Display it

$
0
0

Hi. I'm trying to pass a List from one view to another, using the MVVM pattern. In my project, I want to store the questions from a List (questions) into another list (errores) and I want to display "errores" in another view. Basically, whenever the wrong True/False button is pressed, I want to store the question into "errores".

Here's what I've tried:

{
    private List<string> errores;

    public RESULTSPAGE2(List<string> errores)
    {
        InitializeComponent();

        MainListView.ItemsSource = errores;


    }


    }
}

//RESULTSPAGE2.xaml
<ContentPage.Content>
        <StackLayout>
            <ListView 
             x:Name="MainListView"   />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>








class QuizPageModel : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    void OnPropertyChanged([CallerMemberName] string name = "")
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
    }

    public List<Question> questions;

    List<string> errores = new List<string>();



    private string _textopregunta;

    public string TextoPregunta
    {
        get
        {
            return _textopregunta;
        }

        set
        {
            _textopregunta = value;
            OnPropertyChanged();
        }
    }

    //Add Color
    /* private Color _BackgroundFalseButton;

     public Color BackgroundFalseButton
     {
         get
         {
             return _BackgroundFalseButton;
         }
         set
         {
             _BackgroundFalseButton = value; //You must implement INotifyChanged
             OnPropertyChanged(nameof(BackgroundFalseButton));
         }

     }*/



    private bool _wrongAnswer;
    public bool WrongAnswer
    {
        get
        {
            return _wrongAnswer;
        }

        set
        {
            _wrongAnswer = value;
            OnPropertyChanged();
        }
    }


    private bool _currentAnswerValue;
    public bool CurrentAnswerValue
    {
        get
        {
            return _currentAnswerValue;
        }

        set
        {
            _currentAnswerValue = value;
            OnPropertyChanged();
        }
    }

    private int _totalQuestions;
    public int TotalQuestions
    {
        get
        {
            return _totalQuestions;
        }

        set
        {
            _totalQuestions = value;
            OnPropertyChanged();
            OnPropertyChanged(nameof(TitleText));
        }
    }

    private int _currentQuestionNumber;
    public int CurrentQuestionNumber
    {
        get
        {
            return _currentQuestionNumber;
        }

        set
        {
            _currentQuestionNumber = value;
            OnPropertyChanged();
            OnPropertyChanged(nameof(TitleText));
        }
    }

    public string TitleText
    {
        get { return $"Question {_currentQuestionNumber} of {_totalQuestions}"; }
    }

    private int score;

    private Random random;

    public Command AnsweredTrue { get; }
    public Command AnsweredFalse { get; }
    public string QuestionText { get; }



    public QuizPageModel()
    {
        // initialise RNG
       random = new Random();

        // populate question list - replace with external data source in production
        questions = new List<Question>()
        {
            new Question() { QuestionText="1=2", Answer=false } ,
            new Question() { QuestionText="2+2=3", Answer=false },
            ..........
        };



            // initialise quiz values
            TotalQuestions = questions.Count;
        CurrentQuestionNumber = 1;
        score = 0;

        // load first question
        LoadQuestion();



        //True/False

        AnsweredTrue = new Command<Question>(async (question) =>
        {
            Debug.WriteLine("True button pressed");


            /* AnsweredTrue = new Command(async () =>
             {
             Debug.WriteLine("True button pressed");*/

            // check if answer is correct
            if (_currentAnswerValue == true)

                score++;



            else
            {

                errores.Add(QuestionText);


            }


        // load next question or results page
        if (CurrentQuestionNumber < TotalQuestions)
        {
            // increase question counter
            CurrentQuestionNumber++;
            LoadQuestion();
        }
        else
        {
            Debug.WriteLine("End of Quiz");
            await ShowResults().ConfigureAwait(false);
        }
    });



        AnsweredFalse = new Command(async () =>
        {
            Debug.WriteLine("False button pressed");



            // check if answer is correct
            if (_currentAnswerValue == false)
                score++;

            else
            {
                errores.Add(QuestionText);
                //_wrongAnswer = true;

            }


        /*    if (_wrongAnswer == true)
            {
                errores.Add(QuestionText);

            }

            */

        // load next question or results page
        if (CurrentQuestionNumber < TotalQuestions)
        {
            // increase question counter
            CurrentQuestionNumber++;
            LoadQuestion();
        }
        else
        {
            Debug.WriteLine("End of Quiz");
            await ShowResults().ConfigureAwait(false);
        }
    });
    }


    private void LoadQuestion()
    {
        var index = random.Next(questions.Count);
        TextoPregunta = questions[index].QuestionText;
        CurrentAnswerValue = questions[index].Answer;
        questions.RemoveAt(index);
    }

    // private async Task ShowResults() => await Application.Current.MainPage.Navigation.PushAsync(new LVTest(score, _totalQuestions, errores)).ConfigureAwait(false);
    private async Task ShowResults() => await Application.Current.MainPage.Navigation.PushAsync(new RESULTSPAGE2(errores));

}

}

Crash: PdfSharp.Xamarin.Forms already initialized before

$
0
0

Hi all,

I use PDFSharp.Xamarin.Forms in my app (Android and iOS). I initiated the package in MainActiviy.cs:

This works in general, but sometimes I get a strange error which causes my app to crash:

System.InvalidOperationException: PdfSharp.Xamarin.Forms already initialized before

Where does this error come from and how to solve this?


binding does not exist in current context - OnAppearing

$
0
0

Hi Everyone, Help please! :smile:

This is an accessibility question, and I can't seem to figure out the best way to go about it.
I want to set a variable that is bound to an entity (label.text in this case) in my OnAppearing method. i.e. I want to set the label when the page is loaded.

I've got my xaml page:

<?xml version="1.0" encoding="utf-8" ?>
...

         xmlns:local="clr-namespace:App13"
         x:Class="App13.MainPage">

<ContentPage.BindingContext>
    <local:myViewModel />
</ContentPage.BindingContext>

<StackLayout>

    <Label Text="{Binding myBindingEntry}" 

       HorizontalOptions="Center"
       VerticalOptions="CenterAndExpand" />

    <Button Text="Command Button"
            Command="{Binding btnCommand}"
            HorizontalOptions="Center"
            VerticalOptions="CenterAndExpand"
            />

</StackLayout>


'

And I've created another file, called myViewModel.cs :


using System.ComponentModel;
using System.Windows.Input;
using Xamarin.Forms;

namespace App13
{
class myViewModel : INotifyPropertyChanged
{

    string _myBindingEntry = "nothing!";

    public event PropertyChangedEventHandler PropertyChanged;
    public ICommand btnCommand { private set; get; }

    public myViewModel()
    {

        btnCommand = new Command(
            execute: () =>
            {
                myBindingEntry = "You have clicked the Command Button!";
                RefreshCanExecutes();
            }
            );


    }

    void RefreshCanExecutes()
    {
        ((Command)btnCommand).ChangeCanExecute();

    }

    public string myBindingEntry
    {

        private set
        {
            if (_myBindingEntry != value)
            {
                _myBindingEntry = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("myBindingEntry"));
            }
        }
        get
        {
            return _myBindingEntry;
        }


    }

}

}

And here's my code behind, which is where I want to set myBindingEntry:


using System.ComponentModel;
using Xamarin.Forms;

namespace App13
{
[DesignTimeVisible(false)]
public partial class MainPage : ContentPage
{
// I've tried declaring an instance of myViewModel class, to use later:
myViewModel fmyViewModel = new myViewModel();
public MainPage()
{
InitializeComponent();

    }

    protected override void OnAppearing()
    {

        // here is where I want to set the text of my Label.
        // i should be able to do it by assigning text to myBindingEntry

        // This generates 'The name 'myBindingEntry' does not exist in the current context.
        myBindingEntry = "this is set during OnAppearing";

        // or if I use this, I get:
        // Error CS0272  The property or indexer 'myViewModel.myBindingEntry' cannot be used in this context because the set accessor is inaccessible App13
        fmyViewModel.myBindingEntry = "using an instance of the view model!"

        base.OnAppearing();
    }

}

}

How to share PicsArt pictures with xamarin?

$
0
0

I just edited my photo collection with PicsArt. Now I want to share them with xamarin, how can my xamarin app get PNG, JPG, etc. My problem is that my application icon does not appear in the shared list.
Please help !!!

How to Add Button on last Page in CarouselView?

$
0
0
I have a Welcome page in my App i dont know how to add button on last View Page any can help me ? Im new in Xamarin Forms.

Scrollview inside and outside Absolute Layout is not working

$
0
0

Below is the code I would like to have kinda 3 page scroll view wrapped up inside an absolute layout but doesn't working.

<AbsoluteLayout>
<Frame BackgroundColor="Azure" CornerRadius="20">
    <ScrollView AbsoluteLayout.LayoutBounds="0,0,2,2" AbsoluteLayout.LayoutFlags="All">
        <StackLayout>
        <StackLayout Orientation="Horizontal" Padding="20,20,20,20" HorizontalOptions="Center">
        <Frame WidthRequest="100">
            <StackLayout BackgroundColor="AliceBlue">
                <Image Source="tables.jpg" HorizontalOptions="Center" VerticalOptions="Center" Aspect="Fill"/>
                <Label Text="Tables" HorizontalOptions="Center"/>
            </StackLayout>
        </Frame>
            <Frame BackgroundColor="#CCFFC" WidthRequest="100">
                <StackLayout>
                    <Image Source="tables.jpg" HorizontalOptions="Center" VerticalOptions="Center" Aspect="Fill"/>
                    <Label Text="Tables" HorizontalOptions="Center"/>
                </StackLayout>
            </Frame>
        </StackLayout>
        <StackLayout Orientation="Horizontal" Padding="20,20,20,20" HorizontalOptions="Center">
                <Frame BackgroundColor="#CCFFC" WidthRequest="100">
                    <StackLayout BackgroundColor="AliceBlue">
                    <Image Source="tables.jpg" HorizontalOptions="Center" VerticalOptions="Center" Aspect="Fill"/>
                    <Label Text="Tables" HorizontalOptions="Center"/>
                </StackLayout>
            </Frame>
                <Frame BackgroundColor="#CCFFC" WidthRequest="100">
                    <StackLayout>
                    <Image Source="tables.jpg" HorizontalOptions="Center" VerticalOptions="Center" Aspect="Fill"/>
                    <Label Text="Tables" HorizontalOptions="Center"/>
                </StackLayout>
            </Frame>
        </StackLayout>
            <StackLayout Orientation="Horizontal" Padding="20,20,20,20" HorizontalOptions="Center">
                <Frame BackgroundColor="#CCFFC" WidthRequest="100">
                    <StackLayout BackgroundColor="AliceBlue">
                        <Image Source="tables.jpg" HorizontalOptions="Center" VerticalOptions="Center" Aspect="Fill"/>
                        <Label Text="Tables" HorizontalOptions="Center"/>
                    </StackLayout>
                </Frame>
                <Frame BackgroundColor="#CCFFC" WidthRequest="100">
                    <StackLayout>
                        <Image Source="tables.jpg" HorizontalOptions="Center" VerticalOptions="Center" Aspect="Fill"/>
                        <Label Text="Tables" HorizontalOptions="Center"/>
                    </StackLayout>
                </Frame>
            </StackLayout>
        </StackLayout>
    </ScrollView>
</Frame>
</AbsoluteLayout> 

Highlight the image xamarin forms

$
0
0

Hi,
My question is about how we can highlight the captured image,

please help me to solve this issue.

Calling Web API's In Xamarin Forms

$
0
0

I'm a newbie to Xamarin and i try to learn how to call Web API's from Xamarin Forms. I was trying to run this example https://docs.microsoft.com/en-us/samples/xamarin/xamarin-forms-samples/webservices-todorest/ , at my Android Phone(Visual Studio Debugger), but i am getting a System.NotImplementedException in this methode:
[assembly: Dependency(typeof(HttpClientHandlerService))]
namespace TodoREST.Droid
{
public class HttpClientHandlerService : IHttpClientHandlerService
{
public HttpClientHandler GetInsecureHandler()
{
HttpClientHandler handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) =>
{
if (cert.Issuer.Equals("CN=localhost"))
return true;
return errors == System.Net.Security.SslPolicyErrors.None;
};
return handler;
}
}
}

The exception occurs at this line:
handler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) =>
{
if (cert.Issuer.Equals("CN=localhost"))
return true;
return errors == System.Net.Security.SslPolicyErrors.None;
};

Can anyone help me with this?

Thanks in advance.

System.ObjectDisposedException: 'Cannot access a closed Stream.'

$
0
0

This Exception occurs when I push a button so many time in a short time. Why this happen? If I do it slow, giving some time between press and press it everything is alright. The problem is if you do it quickly. It's about two button, one to increase (+) and the other to decrease (-) a value.


Can I use SQLite Database created in System.Data.SQLite with password in Xamarin.

$
0
0

Hi, I am new to mobile development, I used to develop Desktop in VS 2015, I installed VS 2019 recently, I want to do can use SQLite Database created in System.Data.SQLite with password in Xamarin Forms for mobile Development, and I want to use the existing SQLite Databases and how to attach them in Xamarin Forms Project.

Thanks.

async task cancellation c# xamarin.ios (native)

$
0
0

async task cancellation

this my code
async Task GetStudentOrStaffPhoto(string type, string studentStaffId)
{
try
{
if (Reachability.IsInternetReachable())
{
// Create Singleton instance of the account factory class
SearchFactory searchFactory = SearchFactory.GetInstance;
// Create appropriate account facade instance
var searchFacade = searchFactory.CreateSearchInstance(Entity.Common.SearchTypeEnum.RegularSearch);
var schlCode = NSUserDefaults.StandardUserDefaults.StringForKey(AppConstants.LastSelSchoolCodeUDKey);

                var studentStaffPhotoResponse = await searchFacade.GetStudentOrStaffPhoto(schlCode, type, ids);
                if (studentStaffPhotoResponse.IsResponseSuccess)
                {
                    if (studentStaffPhotoResponse.Response != null)
                    {
                        var indexToUpdate = pageIndex;
                        //foreach (var item in studentStaffPhotoResponse.Response)
                        //{
                        for (int i = 0; i < studentStaffPhotoResponse.Response.Count; i++)
                        {
                            if (studentStaffPhotoResponse.Response[i].Image != null)
                            {
                                byte[] sPhoto = Convert.FromBase64String(studentStaffPhotoResponse.Response[i].Image);
                                if (sPhoto != null)
                                {
                                    searchResults[indexToUpdate].Photo = sPhoto;

                            InvokeOnMainThread(() =>
                            {
                                var visibleRows = SearchResultTableView.IndexPathsForVisibleRows;
                                var lastVisibleRowIndex = visibleRows[visibleRows.Count() - 1].Row;
                                if (indexToUpdate <= lastVisibleRowIndex && pageIndex == 0)
                                {
                                    var cell = (SearchResultCell)SearchResultTableView.CellAt(NSIndexPath.FromRowSection(indexToUpdate, 0));
                                    if (cell != null)
                                    {
                                        //var staffImageView = (UIImageView)cell.ContentView.ViewWithTag(indexToUpdate + 2000);
                                        var studentStaffImageView = cell.ContentView.ViewWithTag(indexToUpdate + 2000) as UIImageView;
                                        if (searchResults[indexToUpdate].Photo != null)
                                        {
                                            studentStaffImageView.Image = new UIImage(NSData.FromArray(searchResults[indexToUpdate].Photo));
                                        }
                                    }
                                }
                            });
                            indexToUpdate += 1;
                        }
                    }
                        }
                    }
                    pageIndex += pageSize;
                    if (pageIndex <= searchResults.Count )
                    {
                        if (Reachability.IsInternetReachable())
                        {
                            await GetStudentOrStaffPhoto( type,  ids);
                        }
                        else
                        {
                            var alert = UIAlertController.Create(SharedConstants.NoInternetTitle, SharedConstants.NoInternetMessage, UIAlertControllerStyle.Alert);
                            alert.AddAction(UIAlertAction.Create(AppConstants.OK, UIAlertActionStyle.Cancel, null));
                            PresentViewController(alert, true, null);
                        }
                    }
                }
                else if (studentStaffPhotoResponse.IsUnauthorized)
                {
                    InvokeOnMainThread(() =>
                    {
                        CommonHelper.ShowUnauthorizedAlert(this);
                    });
                }
                else
                {
                    InvokeOnMainThread(() =>
                    {
                        var errMsg = !string.IsNullOrEmpty(studentStaffPhotoResponse.ResponseMessage) ? studentStaffPhotoResponse.ResponseMessage : SharedConstants.ServerErrorMessage;
                        var alert = UIAlertController.Create(SharedConstants.ServerErrorTitle, errMsg, UIAlertControllerStyle.Alert);
                        alert.AddAction(UIAlertAction.Create(AppConstants.OK, UIAlertActionStyle.Cancel, (obj) =>
                        {
                            NavigationController.PopViewController(true);
                        }));
                        PresentViewController(alert, true, null);
                    });
                }
            }
            else
            {
                InvokeOnMainThread(() =>
                {
                    var alert = UIAlertController.Create(NSBundle.MainBundle.GetLocalizedString(AppConstants.NoInternetTitleLKey, ""),
                                        NSBundle.MainBundle.GetLocalizedString(AppConstants.NoInternetMsgLKey, ""),
                                                UIAlertControllerStyle.Alert);
                    alert.AddAction(UIAlertAction.Create(NSBundle.MainBundle.GetLocalizedString(AppConstants.OKLKey, ""),
                                     UIAlertActionStyle.Cancel, (obj) =>
                                     {
                                         NavigationController.PopViewController(true);
                                     }));
                    PresentViewController(alert, true, null);
                });
            }

        }
        catch (Exception ex)
        {
            CommonHelper.LogException(ex, this);
        }
    }

Im getting Error On plugin Connectivity while running my code

$
0
0
I dont know why i got this error but my code is perfectly correct...

```c#
public WelcomePage()
{
InitializeComponent();
CrossConnectivity.Current.ConnectivityChanged += Current_ConnectivityChanged;
}

protected async override void OnAppearing()
{
base.OnAppearing();

if (!CrossConnectivity.Current.IsConnected)
{
await DisplayAlert("Error Title", "Error Msg", "OK");
}
else
{
await DisplayAlert("Connected","Success","ok");
}
}

public async void Current_ConnectivityChanged(object sender, Plugin.Connectivity.Abstractions.ConnectivityChangedEventArgs e)
{
if (!e.IsConnected)
{
await DisplayAlert("Error Title", "Error Msg", "OK");
}
else
{
await DisplayAlert("Connected", "Success","Ok");
}
}

```

How to insert badge in botttom tab on shell page?

$
0
0

I searched alot on internet but found no solution..Badge can be easily inserted in tabbed page but i am using Shell page..Anyone have code how to show badge in bottom tab in shell page?

failed to open APK: Iteration ended.

$
0
0

I'm working in Xamarin forms project from past 6 months. Till now the development went well and after my windows 10 updated yesterday, My xamarin forms android is not getting build successfully. Its throwing error as "failed to open APK: Iteration ended."

Below are the two lines from output window

1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets(155,3): warning APT2258: W/ziparchive(18668): Zip: Entry at offset zero has invalid LFH signature 929c1a24
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Aapt2.targets(155,3): error APT2096: failed to open APK: Iteration ended.

Please help in resolving this asap.

Viewing all 204402 articles
Browse latest View live


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