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

Android build and deploy takes 6min - what can I do?

$
0
0

I've been away from xamarin form android for a bit - I had heard that build and deploy had improved, but I see its as bad as ever...
With no code change a build and deploy for debugging to a Samsung SM-T350 takes over 6min.

Im using VS2019 - on a decent machine, VS is using 2G of memory.

Attached are my project setting - what am I doing wrong here?

Edit:
Followed project settings in this article https://devblogs.microsoft.com/xamarin/optimize-xamarin-android-builds/
Now it is 4min - is that as good as it gets?


In app rating for Android

$
0
0

In our android project we prompt a dialog and direct user to Play Store page of application to rate the app (all the samples I saw are like this).
Is there a way to rate Android app like iOS inside the app with stars and not direct user to store page?

How do I get logs from a Release build?

$
0
0

While developing my application, Console.WriteLine() has served fine as a way to write and read (via VS debug output) log files to track bugs.

Yesterday, I discovered a strange bug in my Release build (incredibly the first difference I have encountered between the two builds). And I suddenly realised that I don't know how to debug this.

Does Console.WriteLine() go anywhere accessible in a Release build - either in the simulator or on a physical device? Is there a better way of doing this?

I seem to recall Xamarin once had some kind of analytics system that allowed me to view errors on a web portal but internet references to this all seem old and I am wondering if it has been retired? Has anything replaced it?

Any advice would be most welcome.

Kind wishes - Patrick

Issue with Prism NavigationBar in Xamarin.forms

$
0
0

Hello Team,
I am using the Prism library in one of the Xamarin form project.
I follow steps given in video https://prismlibrary.com/docs/xamarin-forms/navigation/navigation-basics.html & it's working fine for Android but it's not giving me same behavior for iOS.
For Example
MainPage > Screen A > Screen B > Screen C
Behavior in Android
Here in Android, each screen has a default back button at Navigation bar & If I press the back button from Screen C, It goes to Screen B & if I press the Back button from Screen B then it's going to Screen A.

Behavior in iOS
Each screen has a default back button at Navigation bar & if I press the back button from Screen C, It navigates me to MainPage instead of Screen B.

I need the below kind of Behavior in my app for iOS.
Navigation Stack : MainPage > Screen A > Screen B > Screen C

MainPage & Screen A Should not have a navigation bar with a back button.
When I navigate to Screen B from Screen A, Screen B should have a Navigation bar with back button & title.
When I navigate to Screen C from Screen B, Screen C Should have also a back button with a title.
Back button action should be the previous screen.

One More Scenario & behavior in iOS.
App.xmal.cs

MainPage opening by below Code.

MainPage = new NavigationPage(new MainPage())
                {

                };

Screen A opening from MainPage from below code.

await navigationServ.NavigateAsync("ScreenA", null, false, true);

Screen B opening from Screen A from below Code.

await navigationService.NavigateAsync(new Uri("NavigationPage/ScreenB", UriKind.RelativeOrAbsolute));

Screen C opening from Screen B from below code.

await navigationService.NavigateAsync(new Uri("/ScreenC", UriKind.Relative));

Not sure why it's giving 2 navigation bars at Screen C in place of a single one.

Can someone help me?

Thanks in Advance.

expected behavior of the Accessibility examaple of Microfoft?

$
0
0

Helllo

I tried the example (Xamarin.Forms - Accessibility) app out of interest.

If I compel it for Android the accessibility seems to work.

If I compile the same code, without any changes, for iOS VoiceOver only announces AutomationProperties values to e.g. "Instructions Label" the text on the screen "Accessibility Demo".

This behaviour makes no sense to me, as a screen reader user.

Have I missed something?

Best regards

Petra Ritter

PS. The system does not let me post my questions with a link to the example in it. Sorry about that. You shout be able to finde the example by copy Xamarin.Forms - Accessibility in to google.

How to Add Playstore Services to Android Simulator in VisualStudio

$
0
0

Hi,

I am integrating Google Pay in My Mobile Application and I would like to test if the payment is routed to GooglePay.

Could someone help me installing Playstore Services/GPay in the simulator of Visual Studio?

Regards,
Mahesh B

Using Rg.Plugins.Popup, PopUp ListView Page, How to return the selected item back to the page?

$
0
0

I'm Using Rg.Plugins.Popup, and "Popping" a ListView Page with a bunch of clients in the listview and i want to return a cliente selected back to the page that a was before, I try something like this...

            ClientsListView.ItemTapped += async (sender, args) =>
            {
                ClientsListView.SelectedItem = null;
                var item = args.Item as Clientes;
                if (item == null) return;
                await Navigation.PopPopupAsync(item);
            };

But obviously this didn't work...

Some help would be great...

Make webclient Openread async

$
0
0

My apps in xamarin form is populate by a json file i download online then i need to be sure device have internet access.

I try this but it freeze UI and timeout not seam to be used then i like to make it async.

protected override async void OnAppearing()
{
if (CheckForInternetConnection() == true)
{
isinternet.Text = "Internet ok";
}
else
{
isinternet.Text = "Internet down";
}

      //  await Navigation.PushAsync(new MainPage());
    }

private void CheckClicked(object sender, EventArgs e)
{
if (CheckForInternetConnection() == true)
{
isinternet.Text = "Internet ok";
}
else
{
isinternet.Text = "Internet down";
}

}

public static bool CheckForInternetConnection() {

    try
    {
        using (var client = new MyWebClient(5000))

        using (client.OpenRead("http://google.com/generate_204"))
            return true;
    }
    catch
    {
        return false;
    }
}

with this class

public class MyWebClient : WebClient
{

private int timeout;
public int Timeout
{
get
{
return timeout;
}
set
{
timeout = value;
}
}

public MyWebClient()
{
this.timeout = 10000;
}

public MyWebClient(int timeout)
{
this.timeout = timeout;
}
}


Display Controls Dynamically with MVVM

$
0
0

Hi everyone, I am using MVVM architecture. What I am trying to accomplish is to generate dynamic controls(content views) based on clicking buttons. For example, when I click button A, content view A displays, and when I click button B, content view B displays. Since I am trying to stick to MVVM, I am using "IsVisible" property to dynamically show and hide the content views A and B. However, what layout should I use to hold content views A and B? If I use "StackLayout", the problem is that ViewB will be below ViewA, no matter if ViewA is visible or not. If I use "Grid" layout, then the controls in ViewA, such as Entry, will not work because it is overwritten by ViewB, no matter if ViewB is visible or not. Thanks!

"


</StackLayout or /Grid>"

How to clear the Navigation Stack in a Xamarin.Forms 4.0+ Shell app?

$
0
0

I like to remove all pages from the navigation stack and make my current page the new root page. How can I do that?
Whole navigation is done with the new Shell navigation (calling Shell.GoToAsync(route) or the Flyout Menu).
I tried collecting the current stack from Shell.Current.CurrentItem.Navigation.NavigationStack and Shell.Current.Navigation.NavigationStack , but the only element in there is null for any reason.
I am using the latest Xamarin 4.2.848062 version.

why navigation between pages in xamarin forms is slow on Android

Hamburger menu AutomationId for UI Testing.

$
0
0

I'm trying to run a UI Test on a page (About.xaml).
Below are the steps to get to the page when the application loads.
1. Launch the Login Screen
2. User enters username
3. User enters password
4. User clicks on the Login Button
5. User lands on the Home Page in an AppShell.
6. User clicks on the Hamburger menu
7. User clicks on the About Menu in the Flyout Menu Items.

My question is, how do I set the Automation Id for the Hamburger Menu (Flyout Menu) of the AppShell?

Here's the UI Test Case.

            [Test]
    public async Task AboutPage_UITest()
    {

        //Arange
        app.EnterText("UsernameEntryId", "user1");
        app.EnterText("PasswordEntryId", "Abc@123");


        //Act
        app.DismissKeyboard();
        app.Tap(x => x.Marked("LoginButtonId"));

        app.Tap(x => x.Marked("AppShellId"));
        //app.Tap(c => c.Class("OverflowMenuButton"));  I tried this as well but no luck.
        await Task.Delay(30000);


        app.Tap(x => x.Marked("AboutId"));

        //Assert

        var appResult = app.Query("EmailId").First(result => result.Text == "abc@example.com");
        Assert.IsTrue(appResult != null, "Label is not displaying the right result!");

        app.Screenshot("About Page");
    }

In the AppShell.xaml, here's the top section.

            <Shell xmlns="http://xamarin.com/schemas/2014/forms"
                     xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                     FlyoutHeaderBehavior="CollapseOnScroll"
                     Shell.ItemTemplate="{StaticResource FlyoutTemplate}"
                     Shell.MenuItemTemplate="{StaticResource FlyoutTemplate}"
                     FlyoutBackgroundColor="WhiteSmoke" 
                     Navigating="OnNavigating" 
                     Navigated="OnNavigated"
                     AutomationId="AppShellId"
                     x:Class="DemoApp.AppShell">

ContentPage.ToolbarItems and NavigationPage.TitleView with UWP project

$
0
0

When I use NavigationPage.TitleView block to set a page title, my toolbar icons in ContentPage.ToolbarItems block are pushed to the Secondary menu. This happens only with UWP project while the Android project behaves as expected.

If, however, I move the UWP ToolBar to the bottom in the Application wide App.xaml.cs with the following

MainPage.On<Windows>().SetToolbarPlacement(ToolbarPlacement.Bottom);

it works as expected, except that the top Toolbar is still there as a blank. However, for consistency, I would like the ToolBar to remain in the Top.

Are NavigationPage.TitleView and ContentPage.ToolbarItems mutually exclusive for UWP project, or am I missing something such as disabling some of the UWP features such as its native CommandBar control?

PS: XF is ver 3.4.0.1008975

How to use gesturerecognizer or click in checkbox?

$
0
0

A checkbox added with gesturerecognizer can not be triggered. why?
I want to get its click handler

Accessibility in the CollectionView xamarin forms ios

$
0
0

How can i make the CollectionView work with accessiblility? having added the AutomationProperties to the first child of the DataTemplate, the iOS VoiceOver still does not detect the elements.

Please help me guys! :)


How to disable button for a brief period

$
0
0

Hi All,

I am working on a accessibility device for non-verbal and minimal verbal communicators on the autism spectrum, and I am trying to design my UI to disable certain buttons when the primary user clicks the button but does not enter the correct PIN.

Fair warning, threading in C# is not my strong suite, not even close.

Here is the code I have tried so far:

        private async void Edit_ClickedAsync(object sender, EventArgs e)
        {
            string securityPrompt = await DisplayPromptAsync("Security Check", "PIN");
            int PINNumber;

            if (Int32.TryParse(securityPrompt, out PINNumber))
            {
                if(PINNumber == (Application.Current as App).configuration.GetPIN())
                {
                    // Add edit page code here!
                }
                else
                {
                    //await DisplayAlert("NAH MATE!", "Not happening brah", "Damnit!");
                    await DisableButton((SGDButton)sender,5000);
                }
            }
            else
            {
                await DisableButton((SGDButton)sender, 5000);
            }
        }

        public async Task DisableButton(SGDButton button, int timer)
        {
            await Task.Run(async () =>
           {
               button.IsEnabled = false;
               await Task.Delay(timer);
               button.IsEnabled = true;
           });
        }

The idea is that, for example, should the NV/MVC child press the edit page button and does not enter the correct PIN within the popup, then the button will be disabled for a number of seconds, basically making the child bored with the weird button that doesn't seem to do anything fun (and stops working after you click it).

Any advice on this would be appreciated.

how to draw a waves line using skia sharp?

$
0
0

I want to make a label with a waves underline but it seems there only be a line .

so can it draw a waves line using skiasharp?

Xamarin Bytes to DataSet

$
0
0

I am sending asynchronous client/server bytes but problem is when I use "SELECT" query where I need deserialize bytes send from server. On Xamarin (client) when try convert bytes to dataset it hit exception

The constructor to deserialize an object of type
'System.Data.SimpleType' was not found.

When I test my code on Windows program no exception and work good but Xamarin show exception. Are have a way to convert bytes to dataset/datatable in Xamarin?

           public static DataTable BytestoDataset(byte[] resultsetbyServer)
            {
                DataTable dt = new DataTable();
                try
                {
                    using (MemoryStream memStream = new MemoryStream(resultsetbyServer))
                    {
                        BinaryFormatter brFormatter = new BinaryFormatter();
                        dt = (DataTable)brFormatter.Deserialize(memStream);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message.ToString());
                }
                return dt;
            }

Consume a tap gesture on a view beneath scrollview while maintaining scrolling

$
0
0

Hi all,

I'm trying to use a plugin with parallax effect: https://github.com/DevsDNA/XFParallax and it works great for parallaxview the problem is the header is being overlayed by the body (which is scrollview) which means header (any children in the header) cannot recieve touch gestures since scrollview consumes it. The layout is a grid with a single row which contains the header (contentview) and body (scrollview) on the same row.

I know that the scrollview is consuming touch with scrolling behavior but is it possible to maintain scrolling on entire page and allow header to recieve touch gesture?

Closest to the desired behaviour was setting the parent scrollview IsEnabled to false which allowed scrolling but no scrolling for header, but the header was then able to recieve gestures, ideally the whole page is scrollable but header (or children nested in the header) can recieve tap gestures otherwise if user scrolls on header it just scrolls.

Parralax view:

 <ContentView.Content>
        <Grid>
            <ContentView
                x:Name="Header"
                HorizontalOptions="FillAndExpand"
                VerticalOptions="FillAndExpand" />
            <ScrollView
                x:Name="ParentScroll"
                x:FieldModifier="Public"
                HorizontalOptions="FillAndExpand"
                IsEnabled="False"
                VerticalOptions="FillAndExpand">
                <ContentView x:Name="Body" />
            </ScrollView>
        </Grid>
    </ContentView.Content>

Just trying to make a parallax view with a header that can recieve either tap gesture or scrolling depending how user interacts.

How can I programmatically render an AbsoluteLayout?

$
0
0

I have an Android app, created with XF, where I need to display a PDF on a second screen.
There is a default PDF forms that is used most of the times, however a user can supply a custom PDF or image that should then be displayed instead.
As the values are dynamic and change depending on the app's current dataset, I thought about using the empty PDF as a background image and settings Labels with DataBinding above it instead of filling the form via code.
However, when I use an AbsoluteLayout, it cannot get it to render properly. I can only see a white screen, probably because the renderer created by Platform.CreateRendererWithContext is DefaultRenderer for the AbsoluteLayout.

Here is what my current code looks like:
XAML:

<ContentView
    xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"

    x:Class="Shared.Controls.SecondScreenSheet">

    <AbsoluteLayout
        BackgroundColor="White"
        Padding="100, 64"
        VerticalOptions="CenterAndExpand"
        HorizontalOptions="FillAndExpand">

        <Image
            AbsoluteLayout.LayoutFlags="All"
            AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
            Source="pdfbackground.png"
            Aspect="AspectFit" />

        <Label
            Text="Test"
            TextColor="Red" />

    </AbsoluteLayout>

</ContentView>

Service to display UI on the second screen:

private static readonly DisplayManagerCompat _displayManager =
    DisplayManagerCompat.GetInstance(Xamarin.Essentials.Platform.AppContext);


public void Show(
    Xamarin.Forms.View view)
{
    var displays = _displayManager?.GetDisplays();

    // check if there is a second display
    if (displays?.Skip(1)?.Any() != true)
    {
        return;
    }


    var renderer = Platform.CreateRendererWithContext(
        view,
        Xamarin.Essentials.Platform.AppContext);

    renderer.SetElement(view);

    var secondScreen = displays.Skip(1).First();


    Device.BeginInvokeOnMainThread(() =>
    {
        var presentation = new Presentation(
            Xamarin.Essentials.Platform.CurrentActivity.Window.Context,
            secondScreen);


        presentation.SetCancelable(false);

        presentation.SetContentView(
            renderer.View);


        presentation.Show();
    });
}

I pass the ContentView.Content (which is the AbsoluteLayout) to the service as view parameter.
When I use something simple like a Label, everything works fine as CreateRendererWithContext is able to create a renderer for the XF View.

Is there anything I can do to get this to work with an AbsoluteLayout?
Are there other options that I didn't see yet?

Thanks for your help!

Viewing all 79144 articles
Browse latest View live


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