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

Shell Navigation

$
0
0

Hey guys, I have a little problem about navigation.

My "Menuitem" send me to page "//telaPaginaOpcao" and next step I'm going to 2 pages more, after that I return to //home, but my problem is going to "//telaPaginaOpcao" again.

Routing.RegisterRoute("telaPaginaOpcao", typeof(TelaPaginaOpcao));

telaPaginaOpcao
---telaQtdPedaco
---telaSabor

My Route: //telaPaginaOpcao/telaQtdPedaco/telaSabor

Shell.Current.GotoAsync("//home"); (OK)

When I click again "menuItem", it send me to //telaPaginaOpcao/telaQtdPedaco/telaSabor, but I want to go "//telaPaginaOpcao".

My question is, How Can I do remove "/telaQtdPedado/telaSabor" from my Route.


I'm still learning English, yet... :)


UWP Setting Custom Icon in MapRenderer

$
0
0

I'm trying to draw text on a custom image and set it as a map icon. I've done this with Android and IoS; however, in UWP I've encountered some issues.
The UWP renderer mapIcon.Image requires a uri, stream or file. I've tried several different ways. The following is attempting to return a stream:

public async Task WriteTextOnImage(string uri, string text, Windows.UI.Color color)
{
Uri uriSource = new Uri(uri);
using (CanvasBitmap bitmap = await CanvasBitmap.LoadAsync(CanvasDevice.GetSharedDevice(), uriSource).AsTask().ConfigureAwait(false))
using (CanvasRenderTarget target = new CanvasRenderTarget(CanvasDevice.GetSharedDevice(), (float)bitmap.Size.Width, (float)bitmap.Size.Height, bitmap.Dpi))
{
using (var ds = target.CreateDrawingSession())
{
ds.Clear(Colors.White);
ds.DrawImage(bitmap);
ds.DrawText(text, new System.Numerics.Vector2(150, 150), color);
}
byte[] arr = target.GetPixelBytes();
MemoryStream stream = new MemoryStream(arr);
return stream.AsRandomAccessStream();
}
}

The image is not appearing. I'd appreciate any ideas on this issue.

Need assistance with IOS deployment

$
0
0

Hello,

We have created a simple Xamarin.Forms app. Testing is complete, and we are now deploying to the ~10 persons that will use it.

We have successfully deploy the Android and Windows Apps, but cannot get the IOS app deployed.

The environment:
VS.2019 C#
MacInCloud paired server.
12.9" iPad (iPadOS 13.5.1) to test with for first deployment.

We would like to engage someone for a 1-2 hour consultation to finalize this deployment.

Thanks.

Bryan Hunt

UrhoSharp: How to instanciate a urhosurface only once

$
0
0

I used this xaml example to create my urhosharp project:
https://www.xamarinexpert.it/urhosharp-tutorial-how-to-create-your-first-project-with-xamarin-forms/

The code behind is below.
Is there a way to execute

skyUrho = await urhoSurface.Show<SkyUrho>(urhoApp);

only once (in the constructor?), so that the Model is not executed from the begining when the user navigates back and shaw the page again?
I was thinking about starting a task in the constructor and awaiting it in the OnAppearing method...

    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class SkyUrhoSurface : ContentPage
    {
        private Sight currentSight;
        private SkyUrho skyUrho;
        private INavigation navigation;
        private Urho.ApplicationOptions urhoApp;

        public SkyUrhoSurface()
        {
            InitializeComponent();
            this.currentSight = null;
            urhoApp = new Urho.ApplicationOptions(assetsFolder: "Data");

        }

        protected override async void OnAppearing()
        {
            base.OnAppearing();
            skyUrho = await urhoSurface.Show<SkyUrho>(urhoApp);

            skyUrho.PageVisible = true;
            skyUrho.StarSelection = (currentSight != null);
            buttonShootThisBody.BindingContext = skyUrho;
            labelLat.BindingContext = skyUrho;
            labelLon.BindingContext = skyUrho;
            labelAltitude.BindingContext = skyUrho;
            labelAzimuth.BindingContext = skyUrho;
            labelBodysName.BindingContext = skyUrho;
            labelBodysDirection.BindingContext = skyUrho;
            labelGPSStatus.BindingContext = skyUrho;
            labelDateTime.BindingContext = skyUrho;
            activityIndicator.IsVisible = false;
            activityIndicator.IsRunning = false;
        }
        protected override async void OnDisappearing()
        {
            base.OnDisappearing();
            if (skyUrho != null)
                skyUrho.PageVisible = false;
        }
        void OnCheckBoxNamesChanged(object sender, CheckedChangedEventArgs e)
            {
                if(skyUrho!=null)
                    skyUrho.Names = e.Value;
            }
        void OnButtonShootThisBodyClicked(object sender, EventArgs args)
        {
            if(skyUrho!=null)
                if(skyUrho.SelectedStar!=null)
                    this.currentSight.StarID = (int)skyUrho.SelectedStar;
            navigation.PopAsync();
        }
    }
}

Xamarin forms has NSFileProtectionComplete for default?

$
0
0

Xamarin forms on last version has NSFileProtectionComplete for default?
I'm not sure if this property is active for the latest versions of Xamarin.

Calling MainPage Function from Android App does not work if MainPage is NavigationPage

$
0
0

Help!

In my Android Project I am trying to call a function on the MainPage like this:

(App.Current.MainPage as MainPage)?.ProcessResults(r);

The code compiles but when I execute the code, (App.Current.MainPage as MainPage) is null.

In my App.xaml.cs, my constructor code looks like this:

        public App()
        {
            InitializeComponent();

            MainPage = new NavigationPage(new MainPage());
        }

However, if I change the following line in the constructor from:

MainPage = new NavigationPage(new MainPage());

to:
MainPage = new MainPage();

Then
(App.Current.MainPage as MainPage)?.ProcessResults(r);

Works!

How can I get (App.Current.MainPage as MainPage)?.ProcessResults(r); to work when MainPage = new NavigationPage(new MainPage());?

Thanks

Galaxy Note 9 doesn't show up as deployment device

$
0
0

Hi,

My first time to create an app using Xamarin.Forms for Androin/iOS smartphones. I followed the tutorial for setting up the deployment device. But my phone still doesn't show up as Android device when I debug.

What am I missing?

Appreciate any help.

Passing Object from Shell to Flyout Item Pages

$
0
0

Hello,

I would like to know how to pass an item from the main shell page to flyout pages within the same shell. Or, alternatively, I would like to know if I can simply use an object (which already exists in the scope of the main shell) in its flyout pages. I'm guessing there's some way to do this in the code-behind.

Specifically, I have a login page (which is not a part of the shell) which navigates to the main shell once a user logs in. It passes a Jason web token to the main shell. So I have what I need in the main shell, I just don't know how to use it in the flyout pages!

Any help is greatly appreciated!


Check if renewable subscription is active (Plugin.InAppBilling)

$
0
0

Hello, I am using the InAppBilling plugin to purchase different subscriptions. My problem is, I don't know how to check if a renewable subscription is active. I tried to get this information like this:

var purchases = await CrossInAppBilling.Current.GetPurchasesAsync(ItemType.Subscription);
if(purchases == null)
{
    return false;
}
{
    foreach(var subscription in purchases)
    {
        Console.WriteLine(subscription);
    }
    return true;
}

This is the console output:
ProductId:com.myapp.subscription1 | AutoRenewing:False | State:Purchased | Id:myProductId

I already tried to use the shared secret as payload and get the information with this code snippet:

Console.WriteLine(subscription.Payload);

but the output was always null.
Maybe someone can help me, thanks in advance.

NavigationPage + TabbedPage + "More..." on iOS

$
0
0

I have an app with over 4 tab pages, so the extra ones go under the "More..." tab on iOS.

Due to this bug (https://bugzilla.xamarin.com/show_bug.cgi?id=28378) I currently have my pages set up as:

Navigation -> TabbedPage -> Children

so in App.cs->GetMainPage()

return new NavigationPage(new RootPage());

RootPage extends TabbedPage, and I add children directly to the RootPage

Children.Add(new ChildPage());

The alternative would be having the main page be a tabbed page, and wrapping each child page in a NavigationPage

TabbedPage -> NavigationPage -> ChildPage

But the above listed bug mentions that the tabs under the "More..." section won't be able to PushAsync new pages onto the Navigation, so I can't use this set up.

Main Navigation page set up causes some problems:

a) The main navigation bar has no text.

I haven't tried, but I assume I could dynamically set the parent's title text based on what page is appearing. Or somehow bind the Title to the page title (not sure if that's correct, not super familiar with Bindings)

b) The "More..." pages have double Navigation bars. The main nav bar, and then a second nav bar under it (which fortunately, does have the page's title text in it)


I guess my main question is, both setups have problems. The NavigationPage wrapped Children is unusable due to the PushAsync bug, so should I continue trying to get the Navigation wrapped TabbedPage working? Does any one have some experience / suggestions?

CheckBox prevent automatic visual setting variable

$
0
0

Hi all,

I curious, is there a way to update state of CheckBox only when it is changed in property ?

Consider the following code:

class SomeObject
{
  ...
  private bool _somevalue;
  public bool IsEnabled
  {
    get => _somevalue;
    set
    {
       // _somevalue is not updated immediately, but will be updated later
       // But when setter has finished value of CheckBox is set to checked and it is not desired  behavior
    }
  }
  ...
}

In example below I described the issue in details ...

Ant help would be appreciated !!

Best way to display a floating tooltip ?

$
0
0

Hello community,

I'm still new to Xamarin Forms but so far I love it.

I have an idea and I really don't know how to realize it. I want like to display a floating Tooltip when the user tap a Label. The Label would be in a StackedLayout (or a Grid) inside a Scroll View.

Can you guide me ?

Thanks

Draw a line between two controls

$
0
0

Hello!

I would like to create a simple structure of organizational chart, and so far, i'm dynamically adding buttons to StackLayout. When i click a button, i create another one and put him in StackPanel.

Now i would like to create a line, connecting clicked button and newly created one.

I would appreciate any help!

Dependencies issue after refit

$
0
0

Hi

I have installed refit from 'Manage Nuget Packages for solution..' and my dependencies have gone all wrong. Image here;

How can I fix dependencies and use refit at the same time?

Thanks

Regards

Why does Camera2 ControlAfState alternate between null and 2 for Samsung 8 in my XF app?

$
0
0

I am working with a variation on the Camera2Forms app (found here: https://github.com/vtserej/Camera2Forms)

Things were working OK on the Samsung 7 that I had for testing. Then I tried it on a Samsung 8, I got as far as CameraCaptureListener.Process and it crashed on a null exception.
Here is a snippet of the code:

`
switch (owner.mState)
{
case CameraDroid.STATE_WAITING_LOCK:
{
Integer afState = (Integer)result.Get(CaptureResult.ControlAfState);

                    if (afState == null)
                    {
                        System.Diagnostics.Debug.WriteLine(" ** CameraCaptureListener Process STATE_WAITING_LOCK" +
                            " - afState=null");
                    }
                    else
                    {
                        System.Diagnostics.Debug.WriteLine(" ** CameraCaptureListener Process STATE_WAITING_LOCK - afState= "
                            + afState.IntValue());
                    }

                    if (owner.SelectedCamera.HasAutoFocus == false) 
                    {
                        System.Diagnostics.Debug.WriteLine(" ** CameraCaptureListener HasAutoFocus == false");
                        owner.mState = CameraDroid.STATE_PICTURE_TAKEN;
                        owner.TakePhoto();
                    }
                    else if (afState == null) // Note: this is the main part that was added in
                    {
                        break;
                    }
                    else if ((((int)ControlAFState.FocusedLocked) == afState.IntValue()) ||
                               (((int)ControlAFState.NotFocusedLocked) == afState.IntValue()))
                    {
                            // ControlAeState can be null on some devices
                            Integer aeState = (Integer)result.Get(CaptureResult.ControlAeState);

                            if (aeState == null || aeState.IntValue() == ((int)ControlAEState.Converged))
                            {
                                System.Diagnostics.Debug.WriteLine(" ** CameraCaptureListener Process ControlAEState.Converged pre TakePhoto ");
                                owner.mState = CameraDroid.STATE_PICTURE_TAKEN;
                                owner.TakePhoto();
                            }
                            else
                            {
                                System.Diagnostics.Debug.WriteLine(" ** CameraCaptureListener Process pre RunPrecaptureSequence");
                                owner.RunPrecaptureSequence();
                            }
                    }
                    break;
                }

`
When I run this on an S7 it immediately has an afState == 4, carries on and is done nicely.
When I run this on an S8 (Samsung SM G950W on Android 9 - API 28) it comes thru this code a few times alternating between afState is null and afState.IntValue() == 2.

With the code that skips out when afState is null in place, I get a nice preview and can take one picture. After that the preview is so very dark that I can hardly see what the camera is pointing at. I can only see very bright things. BTW, if I take a picture, that all seems to work, but the preview for the next pic is still super dark.

How should I handle the afState == null?
Is there some other code that I should add in?
What is happening in the S8 to cause the alternating null and 2? This is what the output looks like:

[0:]  ** CameraCaptureListener Process STATE_WAITING_LOCK - afState=null
[0:]  ** CameraCaptureListener Process STATE_WAITING_LOCK - afState= 2
[0:]  ** CameraCaptureListener Process STATE_WAITING_LOCK - afState=null
[0:]  ** CameraCaptureListener Process STATE_WAITING_LOCK - afState= 2
[0:]  ** CameraCaptureListener Process STATE_WAITING_LOCK - afState=null
[0:]  ** CameraCaptureListener Process STATE_WAITING_LOCK - afState= 4

Thanks!

Note: I have also posted this question at the github for Camera2Forms.


can xamarin.forms use system.text.json instead of newtonsoft.json?

$
0
0

If I use system.text.json there will be exceptions.

UWP Store Submission failed with error code(s) 1201 after Xamarin.Forms upgrade

$
0
0

I have a UWP Xamarin.Forms app in the Microsoft Store that is based on Xamarin.Forms 4.2.x. I'm trying to release an update of my app. During development I upgraded Xamarin.Forms to 4.4. When building for the store, the local certification process passed without error.

However, when I submit it to Microsoft's Partner Center, it gets rejected almost immediately with error code 1201.

I'm using Visual Studio 2017 15.9.20.

disable specific hardware keyboard keys(e.g. Home & End keys) for Xamarin.UWP desktop application

$
0
0

Is it possible to disable specific hardware keyboard keys(e.g. Home & End keys) in Xamarin.UWP application for whole app.

Socket Closed error

$
0
0

Hi,

I'm developing an application with Xamarin Forms 2.3.4.247, Prism 6.3.0 and the CrossConnectivity Plugin for Xamarin.

My application does a lot of http requests, and every time I make one I do this check.
CrossConnectivity.Current.IsConnected
and then
CrossConnectivity.Current.IsRemoteReachable(url)

but sometimes when later executing my http requests to the same URL, I get the error Socket Closed

I'm using System.Net.HttpClient for http requests. The error is random and happens with various hosts. I haven't been able to reproduce the error at will, it occurs erratically.

Is there any way of finding the cause of this error? Does anybody know how to fix it?

Listview graphic glitch

$
0
0

Good morning,
As you can see in the photo, the writings on the right are cut. I have already tried several combinations of verticaloptsions and horizontaloptions. No combination can give me the result I want. What I would like is that the cell automatically widens with respect to the length of the text.

This is my code

`<Frame CornerRadius="20" Padding="0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" HasShadow="True" IsClippedToBounds="True" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="10">
                <StackLayout BackgroundColor="#f5f5ff" Grid.Column="0" Grid.ColumnSpan="2" Padding="10,10,10,5" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                    <ListView x:Name="timelineListView" ItemTapped="timelineListView_ItemTapped" ItemsSource="{Binding .}" RowHeight="75" SeparatorVisibility="None" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" BackgroundColor="Transparent">
                        <ListView.ItemTemplate>
                            <DataTemplate>
                                <ViewCell>
                                    <Grid HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="100" />
                                            <ColumnDefinition Width="30" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*" />
                                            <RowDefinition Height="*" />
                                        </Grid.RowDefinitions>

                                        <Label Grid.Row="0" Grid.Column="0" HorizontalOptions="Center" Style="{StaticResource StepTimeLabel}" Text="{Binding SWHEN, StringFormat='{0:H:mm}'}" />
                                        <Label Grid.Row="1" Grid.Column="0" HorizontalOptions="Center" Style="{StaticResource StepTimeLabel}" Text="{Binding SWHEN, StringFormat='{0:dd/MM/yyyy}'}" FontSize="Small"/>
                                        <BoxView Grid.Row="0"  Grid.Column="1" Grid.RowSpan="2" BackgroundColor="#9a9a9a" HorizontalOptions="Center" IsVisible="{Binding IsLast, Converter={local:NotBooleanConverter}}" VerticalOptions="FillAndExpand" WidthRequest="3" />
                                        <Image Grid.Column="1" HorizontalOptions="Center" VerticalOptions="Center">
                                            <Image.Source>
                                                <OnPlatform x:TypeArguments="ImageSource" 
                                                        Android="Bullet.png"
                                                        WinPhone="Images/Bullet.png"/>
                                            </Image.Source>
                                        </Image>
                                        <Label Grid.Row="0" Grid.Column="2" Padding="5,5,0,0" Style="{StaticResource StepTimeLabel}" Text="{Binding SLNAME}" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" />
                                        <Label Grid.Row="1" Grid.Column="2" Padding="5,0,0,0" MaxLines="2" Style="{StaticResource StepTimeLabel}" Text="{Binding SLEMAIL}" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"/>
                                    </Grid>
                                </ViewCell>
                            </DataTemplate>
                        </ListView.ItemTemplate>
                    </ListView>
                </StackLayout>
            </Frame>`

Thankyou,
David.

Viewing all 79144 articles
Browse latest View live


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