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

how to maintain the position of controls in same app for different android smartphones

$
0
0

Hi, i recently finished making a cross platform application. i was testing only on a single device(android) when i tested it on another smartphone(android) there was some slight variation in the position of labels,buttons and hyperlinks. can somebody help me out in maintaining the uniformity for all devices.
Thanks


Xamarin Shell Navigation while flicker at the bottom of the tab

$
0
0

Is anyone else experiencing what appears to be a white flicker at the bottom of the tab when navigating in shell? This only appears if I actually use the Shell Navigation technique: await Shell.Current.GoToAsync("//Parent/Child");

If I do the following I do not see a flicker
await Shell.Current.Navigation.PushAsync(new Child());

I want to add google AdsMob in my app.

$
0
0

I want to add admobs in my app.How can I do?
Can you recommend me links or somethings about google admobs?

How to resolve [msbuild] Microsoft.CSharp.Core.targets was not found

$
0
0

I am using xcode version 10, visual studio 2017, mac os Mojave. while building the application getting the Error:---
VisualStudio/7.0/MSBuild/9435_1/Microsoft.CSharp.CurrentVersion.targets(5,5): Error MSB4019: The imported project VisualStudio/7.0/MSBuild/9435_1//Microsoft.CSharp.Core.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. (MSB4019). Any suggestions please ?

Grouped Horizontal Listview

$
0
0

I'm trying to make a grouped listview with the items (which just consist of an image and a title underneath the image) in each group side by side rather that in a single column. Has anyone done anything similar or have any recipes for something like this? It seems like it should be an easy thing to do, but I haven't been able to find any examples or anything.

QRCode/BarCode Scanning

$
0
0

I am using Zxing library to scan the QR/Barcode Images, but It is not perfect as iOS native scanning. is there any better solution rather than Zxing to scan QRCode/Barcode ?

Any help is appreciated.

An alternative to BTProgressHUD.ShowToast? Currently results in JIT error (debug mode)

$
0
0

The full error is the following, which was not particularly helpful in helping to track down that it was the invocation of BTProgressHud.ShowToast as the root cause.

Assertion at interp.c condition is_ok (error) not met function:do_jit_call, Attempting to JIT compile method wrapper other void object gsharedvt_out_sig while running in aot-only mode

See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.  assembly:<unknown assembly> type:<unknown type> member:(null)

I've seen similar reports online with JIT and iOS saying that this can be caused by running in debug mode, so for now I've got a #if DEBUG to display a normal dialog in debug mode, but attempt to call BTProgressHud.ShowToast in release mode, but I'd like to understand why this is suddenly happening all of a sudden.

I had the issue with XF 4.5.0.530 so I updated to the latest Xamarin.Forms 4.6.0.616-pre4, I also update all the .NET / App Center libraries etc, but the problem persists.

Q1 - What changed that causes this library that has been stable to no longer work?

Q2 - Is there a good library for toast / popup messages that fade away after x seconds?

Screenshot of iOS build settings...

Screenshot of iOS build settings

Is API for Dialog / Navigation common across XF and WPF ?

$
0
0

In Prism navigation / dialog services are all platform specific... right ? The reason I am asking is that I've noticed that there are separate interfaces for
1) DIALOG interfaces (IDialogService, IDialogAware and IDialogParameters) and for
2) NAVIGATION interfaces (INavigationService, INavigationAware, and INavigationParameters)

Since these interfaces are are not part of the prism (core) should we assume that there is no common API accross XF and WPF ?


App crash when distributed in app bundle format

$
0
0

When i release as "bundle", i got this crash : (At the beginning page)

But apk format it works,

My android options :
dex compiler : dx
code shrinker : ProGuard
linker : Sdk Assemblies Only

Grouping CollectionView With Horizontal Orientation

Xamarin forms pinch and pan gesture together

$
0
0

Hi,
I spent too much time to check all the post and for searching for code who permit pinch and pan gesture in same time. All the time, for me, there is a bug or a problem with the code. I changed the Microsoft code for have a pinch and pan that work really great.

Create a Content Page
Add the reference :
xmlns:local="clr-namespace:applicationname"

Add image on your form, I put FillAndExpand to be sure that all the layers take all the screen place :

<local:PinchPanContainer.Content HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">

</local:PinchPanContainer.Content>

Create a class name PinchPanContainer.cs. The OnPinchUpdated is a copy-paste in the Microsoft code but I added a bool blnDisableMove to disable the first pan move after a pinch move. On real device, not on simulator, when you pinch gesture some time you pan in same time. This result to pinch gesture that work very well, but at the end your image goes to the wrong location because the panning motion run afterwards. Anyway, on real device you don't see any delay with the pan move. The OnPanUpdated is a combinaison of the Microsoft code and the code in this post : I can't publish a url because I'm a new user and I what to share my code to help others one. I add the scale factor to the Microsoft code and I add my bool blnDisableMove to set this one to false to permit the pan move after the first completition. I also replace the App.ScreenWidth on the Microsoft code because this code doesn't seem to exist anymore. I replace with this Application.Current.MainPage.Width. In my initial code the Application.Current.MainPage.Width and Application.Current.MainPage.Height was Content.Width and Content.Height because I set the to take all the screen and it work really great.

using System;
using Xamarin.Forms;

namespace jardins
{
public class PinchPanContainer : ContentView
{
double currentScale = 1;
double startScale = 1;
double xOffset = 0;
double yOffset = 0;
bool blnDisableMove = false;

    public PinchPanContainer()
    {
        var pinchGesture = new PinchGestureRecognizer();
        pinchGesture.PinchUpdated += OnPinchUpdated;
        GestureRecognizers.Add(pinchGesture);

        var panGesture = new PanGestureRecognizer();
        panGesture.PanUpdated += OnPanUpdated;
        GestureRecognizers.Add(panGesture);
    }

    void OnPanUpdated(object sender, PanUpdatedEventArgs e)
    {
        if (Content.Scale == 1)
        {
            return;
        }

        switch (e.StatusType)
        {
            case GestureStatus.Running:

                if (!blnDisableMove)
                {
                    Content.TranslationX = Math.Max(Math.Min(0, xOffset + (e.TotalX * Scale)), -Math.Abs((Content.Width * Content.Scale) - Application.Current.MainPage.Width));
                    Content.TranslationY = Math.Max(Math.Min(0, yOffset + (e.TotalY * Scale)), -Math.Abs((Content.Height * Content.Scale) - Application.Current.MainPage.Height));
                }

                break;

            case GestureStatus.Completed:

                if (blnDisableMove)
                {
                    blnDisableMove = false;
                    return;
                }
                // Store the translation applied during the pan
                xOffset = Content.TranslationX;
                yOffset = Content.TranslationY;
                break;
        }
    }

    void OnPinchUpdated(object sender, PinchGestureUpdatedEventArgs e)
    {
        if (e.Status == GestureStatus.Started)
        {
            // Store the current scale factor applied to the wrapped user interface element,
            // and zero the components for the center point of the translate transform.
            startScale = Content.Scale;
            Content.AnchorX = 0;
            Content.AnchorY = 0;
            blnDisableMove = true;
        }
        if (e.Status == GestureStatus.Running)
        {
            // Calculate the scale factor to be applied.
            currentScale += (e.Scale - 1) * startScale;
            currentScale = Math.Max(1, currentScale);

            // The ScaleOrigin is in relative coordinates to the wrapped user interface element,
            // so get the X pixel coordinate.
            double renderedX = Content.X + xOffset;
            double deltaX = renderedX / Width;
            double deltaWidth = Width / (Content.Width * startScale);
            double originX = (e.ScaleOrigin.X - deltaX) * deltaWidth;

            // The ScaleOrigin is in relative coordinates to the wrapped user interface element,
            // so get the Y pixel coordinate.
            double renderedY = Content.Y + yOffset;
            double deltaY = renderedY / Height;
            double deltaHeight = Height / (Content.Height * startScale);
            double originY = (e.ScaleOrigin.Y - deltaY) * deltaHeight;

            // Calculate the transformed element pixel coordinates.
            double targetX = xOffset - (originX * Content.Width) * (currentScale - startScale);
            double targetY = yOffset - (originY * Content.Height) * (currentScale - startScale);

            // Apply translation based on the change in origin.
            Content.TranslationX = targetX.Clamp(-Content.Width * (currentScale - 1), 0);
            Content.TranslationY = targetY.Clamp(-Content.Height * (currentScale - 1), 0);

            // Apply scale factor.
            Content.Scale = currentScale;

            blnDisableMove = true;
        }
        if (e.Status == GestureStatus.Completed)
        {
            // Store the translation delta's of the wrapped user interface element.
            xOffset = Content.TranslationX;
            yOffset = Content.TranslationY;

            blnDisableMove = true;
        }
    }
}

}

Task.Delay for long times doesn't work

$
0
0

I have a Task.Delay() function.

The code activates it, and waits for 10 minutes. Works fine.
The code activates it, suppose to wait 1 hour, but it always waits more ! (more = few minutes more).

I thought it because the app enters a sleep mode, but when I lock the phone,
the app enters to a sleep mode and it works fine.

Does someone have an idea?
The device is an Android device, and I develop the app using Xamarin.Forms.

This is the code:
try{
_myTask= Task.Delay(TimeSpan.FromSeconds(secondsToWait), someTokenForCancel);

     //some code..

     await _myTask;
}catch(TaskCanceledException e)
{
    //some code.. 
}

Want to show the 1st page of a TabbedPage OnResume() in iOS

$
0
0

When app started or resumed in Android I see the 1st page of a TabbedPage. But in iOS on resume it shows the last current page. I want to show the 1st page on resume also in iOS. Is it possible?

SkiaSharp drawing issue inside CollectionView

$
0
0

I have a SKCanvasView inside CollectionView

    <CollectionView ItemsSource="{Binding Icons}" >
        <CollectionView.ItemsLayout>
            <GridItemsLayout Orientation="Vertical" VerticalItemSpacing="10" Span="4"/>
        </CollectionView.ItemsLayout>
        <CollectionView.ItemTemplate>
            <DataTemplate x:DataType="local:DialogImageListItem">
                <Grid>
                    <skia:SKCanvasView  VerticalOptions="Center" HorizontalOptions="Center" WidthRequest="{Binding IconSize}" HeightRequest="{Binding IconSize}"
                                        PaintSurface="SKCanvasViewIconListItem_PaintSurface"/>
                    <Label Text="{Binding Id}"/>
                </Grid>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>

In SKCanvasViewIconListItem_PaintSurface I just draw a text with number (index of item).
In Android all work fine, however in iOS, it stops redrawing the canvas after first page is scrolled out, and looks like it reuses old canvases randomly.

See screenshot attached.
The black numbers are labels, red ones are SKCanvasView.
They are 1..155, but after scrolling to 40, SKCanvasView is not drawn properly (only on iOS) - the label is rendered properly. On Android, it's ok.
Looking at debug output, SKCanvasViewIconListItem_PaintSurface is indeed not called after item 40 is scrolled into view.

Might be that SKCanvasView.InvalidateSurface is not called on iOS for those items? But then why are random numbers drawn? (Actually, not drawn (SKCanvasViewIconListItem_PaintSurface is not called), in fact, previous SKCanvasViews are re-displayed)
How can I force InvalidateSurface () to be called when those are scrolled into the view?

I logged this issue already to Xamarin, but started to doubt, it might be also SkiaSharp issue (also my fault)??

Project also attached.

Thx

How to navigate from class

$
0
0

All i want is to navigate from my popup class to content page without disable navigation bar i tried Navigation.PushModelAsync() but it disabling the navigation bar


Released some Xamarin.Forms NuGet packages

$
0
0

Hi, I released the following NuGets in case anyone else needs the functionality:

Xamarin.Forms.Chips - Chip support for Xamarin.Forms
Xamarin.Forms.DragView - A draggable pane component for Xamarin.Forms
Xamarin.Forms.SlideView - A sliding view component for Xamarin.Forms
Xamarin.Forms.ExtendedLifecycleContentPage - Extended lifecycle support for Xamaring.Forms.ContentPage

Direct NuGet package URLs:
https://www.nuget.org/packages/Xamarin.Forms.Chips/
https://www.nuget.org/packages/Xamarin.Forms.DragView/
https://www.nuget.org/packages/Xamarin.Forms.SlideView/
https://www.nuget.org/packages/Xamarin.Forms.ExtendedLifecycleContentPage/

They are extremely lightweight and do only the thing it says on the tin can. Hope you find them useful.

How to bind text converter to button text?

$
0
0

I'm trying to bind converter to button text programmatically but the converter is not getting called
descLabel.SetBinding(Button.TextProperty, new Binding("Text", BindingMode.Default, new Converters.CaseConverter(),"s",null,descLabel.Text));
Also the text is not getting displayed.
What can i do for this?
What I'm trying to achieve is the case of button text should not change as for Android, iOS n UWP.
Any inputs appreciated :)

How to intercept Navigation Bar Back Button Clicked in Xamarin Forms?

$
0
0

I have a xamarin forms page where the user can update some data in a form. I need to intercept the Navigation Bar Back Button Clicked to warn the user if some data have not been saved.How to do it?

I'm able to intercept the hardware Bar Back Button Clicked in Android using the Android.MainActivity.OnBackPressed(), but that event is raised only on hardware Bar Back Button Clicked, not on Navigation Bar Back Button Clicked.

I tried also to override Xamarin.Forms.NavigationPageOnBackButtonPressed() but it not works. Why? Any one have already solved that issue?

I also tried by overriding OnDisappear, there are two problems:

The page has already visually disappeared so the "Are you sure?" dialog appears over the previous page.
Cannot cancel the back action.
So,is it possible to intercept the navigation bar back button press?

Thanks for any help on this.

How to set Material DatePicker’s Height?

$
0
0

I'm trying to use the Material design but DatePicker's height doesn't look fit with others. How can I set its height?

iOS

Android

    <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"></RowDefinition>
                    <RowDefinition Height="auto"></RowDefinition>
                    <RowDefinition Height="auto"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <!--Isim-->
                <Entry Grid.Row="0" Grid.Column="0" Visual="Material" Placeholder="Isim" />

                <!--Countries-->
                <Picker Grid.Row="0" Grid.Column="1" Visual="Material"
                        SelectedIndex="0" SelectedItem="Turkey" Title="This is Picker" ItemsSource="{Binding CountryNames}">
                </Picker>

                <!--Soyisim-->
                <Entry Grid.Row="1" Grid.Column="0" Visual="Material" Placeholder="Soyisim" />

                <!--date-->
                <DatePicker Grid.Row="1" Grid.Column="1" Visual="Material" />

                <!--button-->
                <StackLayout Grid.Row="2" Grid.ColumnSpan="2">
                    <Button Command="{Binding LoginCommand}" Text="Login" HeightRequest="50" Visual="Material"/>
                </StackLayout>
            </Grid>

Invoke for Backdoor Method failed with outcome: ERROR No such method found:

$
0
0

I'm trying to Invoke a Backdoor method. when I run the test it gives:
Invoke for MyBackdoorMethod failed with outcome: ERROR No such method found: MyBackdoorMethod()
what is the Probleme ? Could any one help please ?

My backdoor method:
for Android:
[Export("MyBackdoorMethod")]
public void MyBackdoorMethod()
{
// In through the backdoor - do some work.
}
for IOS:
[Export("myBackdoorMethod:")] // notice the colon at the end of the method name
public void MyBackdoorMethod(NSString value)
{
// In through the backdoor - do some work.
}
and in UI test:
[Test]
public void MyTest()
{
new HomePage()
.OpenNavigationMenu();
if(OnAndroid)
{
app.Invoke("MyBackdoorMethod");
}
else if(OniOS)
{
app.Invoke("myBackdoorMethod:", "the value");
}
}

Viewing all 91519 articles
Browse latest View live


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