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

Firebase-How to log exceptions in xamarin.iOS

$
0
0

Hello,

I am implementing Firebase Crashlytics in xamarin forms.I want to log exceptions occurred in try/catch block to firebase.
I am using below line of code to track exception in xamarin android which are reflected as Non-fatal error on firebase portal (Which is achieved).
Android native code-
public void TrackException(Exception exception)
{
Crashlytics.Crashlytics.LogException(Java.Lang.Throwable.FromException(exception));
}

I am using dependency service to call above code in xamarin forms PCL project.
try
{
}
catch(Exception ex)
{
DependencyService.Get().TrackException(ex);
}

Similarly for xamarin.iOS I have method Crashlytics.SharedInstance.RecordError(objNSError);
How can I convert Exception to NSError object in xamarin?

Thanks,
Payal


Handle focus on entry in custom made autocomplete

$
0
0

I have made a autocomplete control - but are not completely happy with how the unfocus of the entry happens

The actual autocomplete consists of a scrollview. Slow dragging inside the ScrollView works, but swipe/swipedragging more aggressively like you would do in a ListView - makes the Entry lose focus. The Autocomplete then closes as I have programmed it to be.

Is there some way I could manually handle the deselection of the entry when the user is interacting with the autocomplete (inside the scrollview)?

webview open new blank page in browser

$
0
0
public MainPage()
    { 
    Title = "XXXXXX";

        var source = new UrlWebViewSource();
    source.Url = "http://XXXXXXXXX/student/studentlogin.aspx";
        var webView = new WebView
        {
            HorizontalOptions = LayoutOptions.FillAndExpand,
            VerticalOptions = LayoutOptions.FillAndExpand,
            Source = source
        };
        webView.Navigating += (s, e) =>
        {
            if (e.Url.Contains("FeeReceipt.aspx"))
            {
                try
                {
                    var uri = new Uri(e.Url);
                    Device.OpenUri(uri);
                }
                catch (Exception)
                {
                }

                e.Cancel = true;
            }

    };
webView.Navigated += (object sender, WebNavigatedEventArgs e) => {
            System.Diagnostics.Debug.WriteLine("Done");
        };

Content = new ContentView {
            Content = new StackLayout {
                Children = {
                    webView
                }
            }
        };
    }

Tool bar menu item xamarin forms

$
0
0
I would like to achieve similar tool bar menu item. I would like to add image in left and text in right. Image is font awesome icon. So I would like to create custom template with label . And show like this menu item . I have tried absolute layout with listview . It not working. I am thinking to use picker but it occupy full screen.but it needs to display like in image .. any one please help on this to overcome issue.

Thanks

Advice to handle html files in external storage

$
0
0

Hi guys, i'm a xamarin newbie. I have developed a simple Forms app to display some particular html files (by webview). To store the files i've used embedded resource. Now i need to implement a mechanism to updates of that files...so i've developed an asp net mvc web api. When i call it returns to me a zipfile with updated contents (they must be stored in the sd card). In your opinion, what is the best way to handle a lot of html files stored in the sd storage? Must i copy them to Asset (or assets are write only..?) to visualize them?

Thank you very much for your advices, i'm a little bit confused.

Barcode reader for handheld devices like zebra and Panasonic devices in xamat

$
0
0
I am developing the barcode reader application which supports only handheld devices like zebra bad Panasonic's devices. Please anyone tell me how to do barcode reader for those devices in XamarinForms.

Thanks in advance

Toolbar menu item customization

$
0
0
I would like to load image url to tool bar menu item. BUT from Google results I found that tool bar menu item accept only drawable image. Is there any possibility to load image url


Icon =Accepting only drawable image.

Requirement

Icon = load image url or font awesome icon.

How to download a file from url in xamarin form

$
0
0

I am trying to download a file from url and I am not using plugin . can any one please help me how to download a file from url.


Linking Assemblies leads to Binding Property not updating

$
0
0

In my Xamarin.Forms app, there is an issue when creating the Release build:

In MyView.xaml, I have a Label with a Text binding:

<Label Text="{Binding ProgressInfo.Message, Mode=TwoWay}" />

In MyViewModel.cs I have the Property:

private (double Value, string Message) progressInfo;
public ( double TotalProgressInPct, string Message) ProgressInfo { get => progressInfo; set => SetProperty(ref progressInfo, value); }

where SetProperty is from a different assembly (MvvmHelpers)

The update of the text label works fine with No Linking, but not with Link SDK Assemblies, where the Label text does not update. All other Labels are updated just fine.

For some reason, the tuple character of the property does not work nice with the Linker? Thankful for any hints!

External ResourceDictionary in several projects

$
0
0

Hey Guys,

I'm trying to include my resource dictionary in several android applications because every app should have the same background, labels .. you know what I mean. :D

What have I tried?

I've had tested if my style and the application work together in the same project. I've created a external .net standardlibrary to centralize it.

    <?xml version="1.0" encoding="utf-8" ?>
    <ResourceDictionary
       xmlns="http://xamarin.com/schemas/2014/forms"
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml">

        <Color x:Key="PrimaryText">#FAFAFA</Color>
        <Color x:Key="SecondaryText">#F5F5F5</Color>
        <Color x:Key="HintText">#80FFFFFF</Color>

I've add the reference (Styles.dll) to my application
When I want to add my style to (e.g.) my labels I use "StaticResource" and "DynamicResource". When I use StaticResource and run the program it throws "Xamarin.Forms.Xaml.XamlParseException: 'Position 40:20. StaticResource not found for key ErrorTextColor'". When I use DynamicResource the application starts but it doesn't take the style.
In app.xaml I've add the namespace and assembly

<?xml version="1.0" encoding="utf-8" ?>
<prism:PrismApplication xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:theme="clr-namespace:Styles;assembly=Styles"
             xmlns:prism="clr-namespace:Prism.DryIoc;assembly=Prism.DryIoc.Forms"

    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
              <theme:BlackStyleDictionary/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</prism:PrismApplication>

After I googled a lot I found out that I actually can use "mergedDictionary" to include it to my project but that doesn't work - also "ResourceDictionary Source="...Path" doesn't work for me.

<Application.Resources>        
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
          <theme:BlackStyleDictionary/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

My App.xaml has "InitializeComponent();" and I tried to build my library as embedded resource, resource and content.
I spent much time to google but don't find an answer so I need you to resolve it. :)

What works?

As I mentioned above when I had my style.xaml in my current app everything works fine, so there is no problem with the resourcedirectionary.

If you need more information for the solution feel free to ask for it. :)

Many thanks in advance,

Esorana

Can I prevent a TapGestureRecognizer from swallowing touches?

$
0
0

I have a custom ViewCell with an Entry in it. I'm using a TapGestureRecognizer in the cell so that I can give focus to the Entry regardless of where the user taps in the cell. In my custom ViewCells without TapGestureRecognizers, I'm able to manage the pressed effect on the cells (adjusting their background color) by using a custom renderer. Unfortunately, the tap effects aren't handled by the custom renderer if the TapGestureRecognizer processes the touch. This leaves me without any sort of pressed effect highlighting for tapping the cell. Is there some way I can prevent the Xamarin TapGestureRecognizer from swallowing touches?

Xamarin Forms Webview doesn't show the tradingview widget.

$
0
0

Hi all,

I use a widget from tradingview site. I would like to make this implementation using xamarin forms webview. However i can't make it works. It just doesn't appear the widget at all.

The same piece of code woks correctly on a browser.
In the html code there is a script tag which the source file is from external resources(from their site).
So i would like to ask if the webview can load javascript resources from the web.

Any help will be appreciated.

Thanks in advance!

I would copy&paste the code but the forum doesn't allow me because every time i paste the code a captcha appear to check if i am human . When i click the check button the whole text disappeared. I try to post code like an answer of this question.

How to execute javascript code in html source of Webview?

$
0
0

My app receives articles from wordpress, through a converter I clean the html code and then with StringBuilder I create the new html string that I feed to a WebView, here I'd like to add an ADV javascript widget (the script is external). Do you believe it is possible?

How can I connect to our internal IIS server from VS debug session?

$
0
0

I've written and deployed an asp.net core 3 web api REST service to our server on our network, which is hosted in IIS, and sending HTTP requests to the service works using Postman. Now I am writing a Xamarin app which needs to connect to this service. All this will be from within our network, so the server is referenced by name and its IP address is always an internal one. When debugging the app in Visual Studio, I cannot reach the server.

The Xamarin project is UWP and Android, and so far I've only been testing on UWP. I can get a response from google.com, but not from our internal server either by name or internal IP address.

[Grouped Listview]: Is it possible to retrieve the group header when item selected?

$
0
0

Hi,

I would like to retrieve the header string (GroupDisplayBinding) when I select an item in the grouped listview.
Is this possible?

Thanks in advance!


Only one page is showing in webview from Google docs

$
0
0

Hello,

I have a document in docs from Google , when page it is opening it is downloading with a progress bar and showing in a Webview.

For so far so good.

But when i make the document longer then one page it is only showing the first page ? and i can't scroll to the next page nr 2

<ContentPage.Content>
    <local:PinchToZoomContainer>
        <local:PinchToZoomContainer.Content>

            <ScrollView>
                <StackLayout>
                    <ProgressBar Progress="0.2"  
             HorizontalOptions="FillAndExpand"  
             x:Name="progress"  
                     ProgressColor="Maroon"
             IsVisible="True"/>
                    <WebView x:Name="Webview"  
         HeightRequest="1000"  
         WidthRequest="1000"  
         Navigating="OnNavigating"  
         Navigated="OnNavigated"  
         VerticalOptions="FillAndExpand"/>
                </StackLayout>
            </ScrollView>
        </local:PinchToZoomContainer.Content>
    </local:PinchToZoomContainer>
</ContentPage.Content>

`

`public Nieuwsbrief()
{
InitializeComponent();
Webview.Source = "https://docs.google.com/document/d/1JtPBbacWjjE1RnqT7MlliexLFk618iNS5yUBBCkh1bs/edit?usp=sharing";
}
protected async override void OnAppearing()
{
base.OnAppearing();

        await progress.ProgressTo(0.9, 900, Easing.SpringIn);
    }

    protected void OnNavigating(object sender, WebNavigatingEventArgs e)
    {

        progress.IsVisible = true;

    }

    protected void OnNavigated(object sender, WebNavigatedEventArgs e)
    {

        progress.IsVisible = false;

    }


}`

Open Source Zebra RFID SDK for Xamarin Forms

$
0
0

Hello,

Zebra Technologies have SDKs for their RFID Scanners on platforms including native iOS, native Android and Xamarin.Android however not for Xamarin.iOS or Xamarin.Forms.

We are currently building a Xamarin.Forms app which critically requires the use of the RFID Scanner (RFD8500 model to be precise) on iOS. Our understanding is that this can be achieved by creating an iOS Binding Library for Zebra's existing Objective-C iOS SDK. I have personally attempted to bind this library through two methods, one being the classic iOS Binding method and two, creating a local C# Nuget Package for consumption. Due to lack of Objective-C experience, both attempts were unsuccessful.

What we would like to know is:

  • Is what we are trying to do even possible? (i.e would a binding library be enough to get the RFID scanners to work with a .forms app)
  • If so, what is the scale of effort?
  • As we lack the technical skills for it, would anybody be up for getting involved in this Open Source? (doing the actual work)

I think this would be a great project to do as over the last few months, I have found that a LOT of developers/companies have suffered from this same issue.

Thank you
Ridhwan

Shell Content page destruction

$
0
0

Using 4.3, say I have 3 tab items, each of them having 2 ShellContent items.
I am using ContentTemplate to only create the times when I click on them.

Now since we have quite a large application we would like to destroy the Tab Items Shell Contents if they select another Tab, is this possible? In general how can we destroy a Content page once it gets the disappear event?

thanks

How to add a ToolbarItem on one platform (Android), but not on the other (iOS)?

$
0
0

Hi there

I have a Xamarin.Forms App for Android and iOS. On one of my Pages I like to add some secondary ToolbarItems for the Android version. I don't want to add them into the Toolbar of an iOS app cause the Xamarin Secondary Toolbar for iOS does not work with the new App Shell.

But with the following XAML I get a NullReferenceException in Page.cs OnToolbarItemsCollectionChanged when I navigate to the page on iOS.

<ContentPage.ToolbarItems>
    <OnPlatform x:TypeArguments="ToolbarItem">
        <On Platform="Android">
            <ToolbarItem Command="{Binding LaunchRocketCommand}" Text="Launch Rocket" Order="Secondary" Priority="3"/>
        </On>
    </OnPlatform>
</ContentPage.ToolbarItems>

Digging into Page.cs I see that the error occurs when the OnToolbarItemsCollectionChanged wants to set item.Parent but I assume item is null cause I did not specify for iOS. Can I somehow manipulate the args.Action? Is it a bug? Does anyone have an idea for a workaround?

    void OnToolbarItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
    {
        if (args.Action != NotifyCollectionChangedAction.Add)
            return;
        foreach (IElement item in args.NewItems)
            item.Parent = this;
    }

Xamarin.Forms: 4.3.0.947036 (latest stable)

Cheers

Hi guys ! Someone knows how to click on a collectionView to display content with mvvm

Viewing all 91519 articles
Browse latest View live