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

Getting a white screen while navigating.

$
0
0

Hi.

I am building a Xamarin.Forms app using PRISM and I am getting the weirdest behavior.
I am pretty sure that it started right after I updated PRISM when the made their IInitialize breaking change.

Here is the flow of my app.
The first screen is the Login page and I am navigating to it in my OnInitialized method in App.xaml.cs

await NavigationService.NavigateAsync("NavigationPage/MainPage");

Once the user is logged in I am using the following line to navigate to the "home" page:

await NavigationService.NavigateAsync("/MainMasterPage/NavigationPage/PlayersHomePage");

This is where I get the white screen for a second and then the tabbed page loads up OK.
I notices that if I remove the Navigation page the white screen does not show up, but I cant do without it.

the PlayersHomePage is a TabbedPage with 3 tabs:

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
            xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
            xmlns:views="clr-namespace:FplMatchdayLive.Views"
            prism:ViewModelLocator.AutowireViewModel="True"
            Title="{Binding Title}"
            x:Class="xxx.Views.PlayersHomePage">
    <TabbedPage.Children>
        <views:TeamPage></views:TeamPage>
        <views:LeaguesPage></views:LeaguesPage>
        <views:FixturesPage></views:FixturesPage>
    </TabbedPage.Children>
</TabbedPage>

in the PlayersHomePage code behinde I am using IInitalize to initialize all the tabs:

public partial class PlayersHomePage : TabbedPage, IInitialize
{
    public PlayersHomePage()
    {
        InitializeComponent();
    }
    public void Initialize(INavigationParameters parameters)
    {
        if (parameters.GetNavigationMode() == NavigationMode.New)
        {
            // Prism always raises OnNavigatedTo on 1st tabbed page so this prevents the first tab being initialised twice
            if (Children.Count == 1)
            {
                return;
            }
            for (var pageIndex = 1; pageIndex < Children.Count; pageIndex++)
            {
                var page = Children[pageIndex];
                (page?.BindingContext as INavigationAware)?.OnNavigatedTo(parameters);
            }
        }
    }
}

I tried removing all the tabs from the TabbedPage thinking its the initialization that is causing this but it did not help.

Any ideas as to how to solve it?


How can I open a local PDF on Xamarin Forms?

$
0
0

Lets say I saved a PDF file to my local project. How can I have a button in Xamarin Forms open the PDF in the devices default viewer? How would I be able to open it in a web browser?

  • I tried opening it in URI with the file path, but that doesn't seem to work.
  • I dont want to make a custom PDF webview, I just want it to open in some default viewer or browser if possible.
  • Opening the pdf file path in Android PrintDocumentAdapter pda = new CustomPrintDocumentAdapter(filePath); seems to work, but this is some print preview view
  • Opening it in UWP with Windows.System.Launcher.LaunchFileAsync(file); seems to work great. Why doesn't Android and iOS have something like this?

MVVM not work with observationCollection?

$
0
0

I have a collection:
public Models.Item Items{get;set;}
in the Models.Item there is a ObservableCollection.
public class Item { public int ItemsCount{get;set;} public ObservableCollection<Models.Users>Users{get;set;} }
and a Property "ItemsCount":
public int ItemsCount{get=>Items.ItemsCount;}

when the Users List changed the ItemsCount not changed. if I use "NotifyPropertyChanged("ItemsCount")" it will give me a exception.

App Center Crashes help!

$
0
0

Hi everybody,

could anybody help shed some light on what these App Center issues could be please. The logs do not give me a lot to work on but if anyone can generally understand the error better then I can it would be a big help.

Different Title Views in Tabbed Page

$
0
0

I have tabbed page in my application and i want to show different title for the each page in the navigation.titleviews. How can achieve this?

How to implement image zooming in Xamarin Forms?

$
0
0

I have tried many online solutions. But I am not able to fix image boundaries and this is not user friendly also.

Thanks in advance.

Managing dependencies of a external SDK

$
0
0

Hi!

I've started a process of building a java binding on top of a SDK provided for us by one of our partners. I'm struggling a bit but little by little I'm managing to make progress. However, the point of this post is not the java binding, but one curious fact that made me wonder about managing dependencies of a SDK, be it one provided for us or one that we have to build ourselves.

The curious fact is: I'm having to import some dependencies that are specific for Android on the front-end application that is consuming the SDK. Why is this happening? For example, in order to run a method from the SDK, the compiler (Visual Studio) asks me to import GoogleGson, Kotlin, Koin, etc. Which are dependencies specific for Android. Shouldn't the SDK wrap them within itself without forcing the application to import them as well? If that situation is to be expected, why does that happen?

I'm pretty sure this is something more in line with the concept of managing dependencies than Java Bindings specifically, which is why I'm posting here. Any light on this subject would be really appreciated.

Set accessibility focus after button click

$
0
0

Hi all,

I am trying to figure out how one would get the accessibility cursor to change focus to an element after a button click. For example when I press a button in my app that is hiding content I want to focus on those new elements that have recently become visible after a button click. Im aware of tab index in XF 4.0, but my understanding of TabIndex is that it only sets the order in which the focus is supposed to follow. I want to set the accessibility cursor on an element that has just been made visible to the user, and then set the order on those new elements. Is anyone aware of how I could accomplish this?

Thanks!


Issue: InstallFailedException

$
0
0

I am currently having an issue with running my Xamarin.Forms app on my mobile device whether it be emulated or my physical test device.
I am on Visual Studio 2019 and it is a new app project and I have had it running before but usually after the first run it does not work again after that if it did.
The error code is as follows:

ADB0010: Mono.AndroidTools.InstallFailedException: Failure [INSTALL_FAILED_INVALID_APK: Package couldn't be installed in /data/app/com.companyname.appname-w4jR_g7Ki-eDsfg24hSJUA==: Package /data/app/com.companyname.appname-w4jR_g7Ki-eDsfg24hSJUA==/base.apk code is missing]
   at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A\_work\254\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 341
   at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.<InstallPackage>b__0(Task`1 t) in E:\A\_work\254\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753
   at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at AndroidDeviceExtensions.<PushAndInstallPackage>d__11.MoveNext() in E:\A\_work\254\s\External\androidtools\Xamarin.AndroidTools\Devices\AndroidDeviceExtensions.cs:line 187
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at AndroidDeviceExtensions.<PushAndInstallPackage>d__11.MoveNext() in E:\A\_work\254\s\External\androidtools\Xamarin.AndroidTools\Devices\AndroidDeviceExtensions.cs:line 203
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Xamarin.AndroidTools.AndroidDeploySession.<InstallPackage>d__112.MoveNext() in E:\A\_work\254\s\External\androidtools\Xamarin.AndroidTools\Sessions\AndroidDeploySession.cs:line 414
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
   at Xamarin.AndroidTools.AndroidDeploySession.<RunAsync>d__106.MoveNext() in E:\A\_work\254\s\External\androidtools\Xamarin.AndroidTools\Sessions\AndroidDeploySession.cs:line 217
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Xamarin.AndroidTools.AndroidDeploySession.<RunLoggedAsync>d__104.MoveNext() in E:\A\_work\254\s\External\androidtools\Xamarin.AndroidTools\Sessions\AndroidDeploySession.cs:line 119

I have tried many things including:
Repairing the SDK
Uninstalling Visual Studio, Android Studio, Android SDK and then re-installing them

Version bumping for for DevOps builds

$
0
0

I used to use a script to
1. Check out appmanifest.xml / info.plist
2. Add +1 to the versioncode
3. Check the file back in again

Now we moved to Azure devops and I'm redoing some of the build-strategies. One thing I came across was James Montemagnos Mobile App Tasks.

From what I can tell, this tasks does not use the old version+1. Instead it uses $Build.BuildId from Azure DevOps (at least as it's example). Nor does it check out/in anything.

Just want to check with the rest of you. What strategy do you use? Checking in the new VersionCode or not?

Getting a white screen while navigating.

$
0
0

Hi.

I am building a Xamarin.Forms app using PRISM and I am getting the weirdest behavior.
I am pretty sure that it started right after I updated PRISM when the made their IInitialize breaking change.

Here is the flow of my app.
The first screen is the Login page and I am navigating to it in my OnInitialized method in App.xaml.cs

await NavigationService.NavigateAsync("NavigationPage/MainPage");

Once the user is logged in I am using the following line to navigate to the "home" page:

await NavigationService.NavigateAsync("/MainMasterPage/NavigationPage/PlayersHomePage");

This is where I get the white screen for a second and then the tabbed page loads up OK.
I notices that if I remove the Navigation page the white screen does not show up, but I cant do without it.

the PlayersHomePage is a TabbedPage with 3 tabs:

<TabbedPage xmlns="http://xamarin.com/schemas/2014/forms"
            xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
            xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
            xmlns:views="clr-namespace:FplMatchdayLive.Views"
            prism:ViewModelLocator.AutowireViewModel="True"
            Title="{Binding Title}"
            x:Class="xxx.Views.PlayersHomePage">
    <TabbedPage.Children>
        <views:TeamPage></views:TeamPage>
        <views:LeaguesPage></views:LeaguesPage>
        <views:FixturesPage></views:FixturesPage>
    </TabbedPage.Children>
</TabbedPage>

in the PlayersHomePage code behinde I am using IInitalize to initialize all the tabs:

public partial class PlayersHomePage : TabbedPage, IInitialize
{
    public PlayersHomePage()
    {
        InitializeComponent();
    }
    public void Initialize(INavigationParameters parameters)
    {
        if (parameters.GetNavigationMode() == NavigationMode.New)
        {
            // Prism always raises OnNavigatedTo on 1st tabbed page so this prevents the first tab being initialised twice
            if (Children.Count == 1)
            {
                return;
            }
            for (var pageIndex = 1; pageIndex < Children.Count; pageIndex++)
            {
                var page = Children[pageIndex];
                (page?.BindingContext as INavigationAware)?.OnNavigatedTo(parameters);
            }
        }
    }
}

I tried removing all the tabs from the TabbedPage thinking its the initialization that is causing this but it did not help.

Any ideas as to how to solve it?

Button Visibility in xamarin forms

$
0
0

i have 20 buttons and need to make condition that if 1st button visibility is True remaining 19 button visibility will be False

How to deal with this binding is ListView ?

$
0
0

Hi all,

My main page is a ListView of some available scores. I am making a favorites system, but I can't do it easily... For now, I have an ObservableCollection, and Score is defined by 4 properties : PageName, DisplayName, Detail, and IsFavorite.

I have a FavoritesManager to manage favorites list (singleton access for multiple pages, and extraction of favorites list from user preferences at startup). My actual system is : when Favorites list changes, it raises OnCollectionChanged event ==> my entire ObservableCollection is rebuilt, just to make one change, the new favorite...

I have this:

public class Score
{
    public string PageName { get; set; }
    public string DisplayName { get; set; }
    public string Detail { get; set; }
    public bool IsFavorite { get; set; }

    public Score(string pageName, string displayName, string detail, bool? isFavorite = null)
    {
        // Do the job
    }
}

public class Category : List<Score>
{
    public string Name { get; set; }
    public Category(string name) { Name = name; }
}


// My ViewModel
public class ScoreListViewModel : ViewModelBase
{
    private ObservableCollection<Category> _categories;
    public ObservableCollection<Category> Categories
    {
        get => _categories;
        set => _categories = SetFieldValueAndNotify(value); // Home-made method to raise event PropertyChanged
    }

    // Access FavoritesManager via Singleton instance
    public FavoritesManager Favorites { get => FavoritesManager.Instance; }

    public ScoreListViewModel()
    {
        this.InitializeCategories();
        this.Favorites.FavoritesList.CollectionChanged += OnFavoritesChanged;
    }

    // Reload Categories when favorites have been updated
    public void OnFavoritesChanged(object sender, NotifyCollectionChangedEventArgs e)
    {
        this.InitializeCategories();
    }

    // Declare / initialize list of categories and scores
    public void InitializeCategories()
    {
        this.Categories = new ObservableCollection<Category>
        {
            new Category ("Foo")
            {
                // Note that I use an indexer here for FavoritesManager, but I can also do it with Favorites.List.Contains();
                new Score("Bar", "Bar_DisplayName", "Bar_Detail", this.Favorites["Bar"])
            }
        };
    }
}

And my XAML:

<ListView
    ItemsSource="{Binding Categories}"
    GroupDisplayBinding="{Binding Name}"
    IsGroupingEnabled="True">

    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <StackLayout Orientation="Horizontal">
                    <StackLayout Orientation="Vertical">
                        <Label Text="{Binding DisplayName}" />
                        <Label Text="{Binding Detail}" />
                    </StackLayout>
                    <Button Text="{Binding IsFavorite}"
                            Command="{Binding Source={x:Reference ThisPage}, Path=BindingContext.ToogleFavorites}" CommandParameter="{Binding PageName}" />
                </StackLayout>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>

</ListView>

My problem is : how can I make a Binging (or anything else ?) to avoid reloading the entire ListView each time I push on a button ?

Note that ideally, I want to keep Score and Category classes "Xamarin-free". So I did not test it with Score.IsFavorite as a bindable property...

Thanks for helping,
Galactose

Create Dropdown Button on Right Navbar

$
0
0

Hey guys, it's my first time asking in this forum so forgive me for my bad english and many more. I'm new in this Xamarin.Forms (android native java before), i want to create a Dropdown Button at right of my Navigation Bar but after few days research and googling i've no clue how to make it. Someone on this forum has make it? Can you please show me how to make it? Thanks before guys :)

What i want:

Share asp.net session between different webviews on iOS

$
0
0

Hello,

We built an application based on hierarchical navigation.
Each time we load a new page we have a webview in it loading an asp.net website.

On android, no problem, asp.net session is shared between all our page.

On iOS, the asp.net session is not shared. We have a different session each time we load a page in the application.
Of course, if we navigate into the same webview, the session is good.

Do you have any idea how we can share asp.net session between 2 different webview instances on iOS?
Why is it working fine on Android but not on iOS ? Where is the difference on the rendered webview ?

Thank you for your help,
Sincerely


Android Only Webview custom protocols "plaidlink://" throwing error "net:ERR_UNKNOWN_URL_SCHEME

"

$
0
0

When implementing a WebView the service provider Plaid uses urls that have custom protocols. We use the Navigating event to evaluate where the customer is in the registration process. This was working and still works on iOS, but now on Android we are receiving net:ERR_UNKNOWN_URL_SCHEME

 when Plaid sends these links.

We need to be able to receive the Navigating event without the webview throwing an error. We know that this was once working

Plaid uses custom protocols to invoke callbacks to the application. On iOS and previously on Android these were and should be ignored and not navigated to. Here are he three links that we receive.
plaidlink://acknowledged?
plaidlink://exit

plaidlink://connected
We get the navigating event and parse these url.

The error we receive now is net:ERR_UNKNOWN_URL_SCHEME



Here is the code snippet we are using.

        var publickey = "********";
        var webhook = "https://hipmoney.hippocket.net/plaidbankaccounts/webhook";
        var url = "https://cdn.plaid.com/link/v2/stable/link.html?isWebview=true&key=" + publickey + "&env=production&product=connect&selectAccount=true&webhook=" + webhook + "&clientName=hipmoney";

        if (!String.IsNullOrEmpty(PlaidProvider.PublicToken))
        {
            url = "https://cdn.plaid.com/link/v2/stable/link.html?isWebview=true&key=" + publickey + "&env=production&product=connect&webhook=" + webhook + "&clientName=hipmoney" + "&token=" + PlaidProvider.PublicToken;
        }

        plaidView = new WebView
        {
            Source = new UrlWebViewSource
            {
                Url = url
            },
            VerticalOptions = LayoutOptions.FillAndExpand,
        };
        this.Content = plaidView;
        plaidView.Navigating += (sender, e) =>
        {
            JObject plaidParams = ParseQueryString(e.Url);

            Debug.log(DateTime.UtcNow + " Navigating " + e.Url);
            if ((string)plaidParams["uri"] == "plaidlink://connected")
            {
                Debug.log(DateTime.UtcNow + " SUCCESS " + e.Url);
                OnSuccess.Execute(plaidParams);
            }
            else if((string) plaidParams["uri"] == "plaidlink://exit") {
                Debug.log(DateTime.UtcNow + " ERROR "+ e.Url);                  
                OnError.Execute(plaidParams);
            }
        };

We don't know what changed, if there was a configuration within the project or a library that was once included but this no longer works on Android, or if it was working by pure chance but we are 100% confident this was working on release sent out 4 weeks ago.

InfiniteScrolling to CollectionView

Loading does not Show

$
0
0

Good Day all

i have a loading functionality that shows on the long running part of my code. it does not show , here is how i use it

                Configurations.LoadingConfig = new LoadingConfig
                        {
                            IndicatorColor = Color.White,
                            OverlayColor = Color.Black,
                            Opacity = 0.4,
                            DefaultMessage = "Sending you an Sms, Please wait...",
                        };

                 await Loading.Instance.StartAsync(async progress =>
                        { 
                            await obj.Generate_Sms_Verification_code(GenericMethods.USER_DATA);

                        });

and the function Generate_Sms_Verification_code is defined like this

 public async Task Generate_Sms_Verification_code(USERS_Model model)
        {
            con = new SqlConnection(strCon);
            cmd = new SqlCommand();
            cmd.CommandText = "dbo.Sms_Verification_code";
            cmd.CommandType = CommandType.StoredProcedure; 
            cmd.Parameters.Add("@PARAMETER", SqlDbType.NVarChar).Value = model.PARAMETER;

             cmd.Connection = con;cmd.CommandTimeout = 0;
            string code = string.Empty;
            try
            {
                con.Open();
                code = cmd.ExecuteScalar().ToString();

                try
                {

                  await  SendSms(GenericMethods.RemoveSpacesIn_String(model.TELEPHONE), "Your APP Code is, " + code + ", Kindly Dont share this code with anyone");
                }
                catch (Exception ex )
                {
                    throw ex;
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
           }

i am using AiForms.Dialogs for Xamarin.Forms which can be found here https://github.com/muak/AiForms.Dialogs#loading

Thanks

MessagingCenter does't working

$
0
0

When I use async , I taking exeption

( I using MessagingCenter for chat app with Firebase Realtime Database )


PlatformNotSupportedException on iOS using Entity Framework Core and Xamarin Forms

$
0
0

Hello community,

I am using Entity Framework Core with SQLite for the first time on Xamarin Forms.

Because I observe the TaskScheduler.UnobservedTaskException, I noticed the following exception, each time I do an operation on EF:

System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Reflection.Emit.DynamicMethod..ctor (System.String name, System.Reflection.MethodAttributes attributes, System.Reflection.CallingConventions callingConvention, System.Type returnType, System.Type[] parameterTypes, System.Type owner, System.Boolean skipVisibility) [0x00006] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection.Emit/DynamicMethod.notsupported.cs:74
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ILEmitResolverBuilder.BuildTypeNoCache (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite callSite) [0x00038] in <29788903d3cf48c4a1368d8b368c6521>:0
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ILEmitResolverBuilder.<.ctor>b__12_0 (Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCacheKey key, Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite cs) [0x00000] in <29788903d3cf48c4a1368d8b368c6521>:0
at (wrapper delegate-invoke)

Because I would like to use it in a large scale production app, I am a bit concerned of this Exception, especially because I don’t know how the underlying framework behaves and if there are any side effects to this.

I have read that “System.Reflection.Emit” is not available on iOS, which I understand.
And the stacktrace indicates that it’s not directly related to Entity Framework, but apparently it’s causing a DI Service lookup which fails.

Any insight on this?

Here is a small demo app for this

Thanks

Viewing all 81910 articles
Browse latest View live


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