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

OpenSource GitHub vs Apk sensitive data

$
0
0

Hello, im creating xamarin app and i want to get it on google play, i've set up everything with all the passwords, keystores, aliases etc. but from what i see it gets saved in .proj file of android project.

How can i load informations from something like a json file that doesnt get commited to the repo? What's the best approach for that


Iconize plugin for Xamarin.Forms - Easily add icon fonts to your projects

UIWebView in Xamarin.iOS seems to ignore external CSS styles?

$
0
0

I'm facing a disturbing problem with showing HTML content in WebView, I've simplified the html content to this for easier reading:

<!DOCTYPE html>
<html lang="en">
    <head>
        <link href="https://www.paytabs.com/theme/payment_page/css/bootstrap.css" rel="stylesheet" type="text/css">
        <link href="https://www.paytabs.com/theme/payment_page/css/custom-rtl.css?timestamp=1540717040" rel="stylesheet" type="text/css">
    </head>

    <body>

<h1 class="text-primary">text one</h1>
<a href="www.stackoverflow.com" class="text-primary">StackOverflow</a>
<div class="container">

                    <div class="header-title"><h3>Xamarin</h3></div>

            </div>
    <h3 class="text-success">Success</h3>
    <img src="https://i.stack.imgur.com/PwBYM.jpg?s=328&g=1" alt="image"/>
    <h1 class="mark">Mark</h1>

    <div class="payment-wrap">
                    <div>
                        <label class="payment_method">
                                <input type="radio" id="creditcard" name="payment_type" value="creditcard">
                                <img src="https://www.paytabs.com/images/img/cards.png" width="75" alt="Credit Card">
                        </label>

                    </div>

                    <div class="form-wrap sadad-hide" style="display:none;">
                        <input class="form-control" placeholder="Enter user" value="" maxlength="12" name="olpalias" id="olpalias" autocomplete="off" type="text">
                    </div>
                    <span class="whats-this sadad-hide" style="display:none;">Don't have account?</span>
                    <!--Sadad Enable-->
                    <div id="pt-sadad-enable-outer">
                        <div id="pt-sadad-enable" class="pt-sadad-enable-wrap pt-arrow">
                        <div class="pt-sadad-enable-inner">
                            <h2>How to activate?</h2>
                            <ul class="pt-sadad-htp">
                                <li class="step1 step-help">
                                    <figure>
                                        <img class="img-help" src="https://www.paytabs.com/images/sadad/p1.png" width="50" height="32">
                                        <figcaption>Activate online</figcaption>
                                    </figure>
                                </li>
                                <li class="step2 step-help">
                                    <figure>                
                                        <img class="img-help" src="https://www.paytabs.com/images/sadad/p2.png" width="48" height="33">
                                        <figcaption>Create sadad account</figcaption>
                                    </figure>       
                                </li>
                                <li class="step3 step-help">
                                    <figure>                                
                                        <img class="img-help" src="https://www.paytabs.com/images/sadad/p3.png" width="27" height="33">
                                        <figcaption>Add to your account</figcaption>
                                    </figure>                       
                                </li>
                            </ul>

                            <a href="https://www.sadad.com/ar/Personal/Pages/RegisterNow.aspx" class="pt-sadad-btn" target="_blank">learn more</a>
                        </div>
                    </div>
                    </div>
                <!-- End Sadad Enable Note-->

                </div>
    </body>

</html>

And here I set the Source of the webView:

 public MainPage()
        {
            InitializeComponent();
            webView.Source = new HtmlWebViewSource
            {
                Html = Resource1.testHtml //containing the HTML above
            };
        }

Here's what's shown on Android (normal):
enter image description here

iPhone:

enter image description here
enter image description here

I tried to use WkWebViewRenderer instead of UIWebView, by adding this in the AssembyInfo.cs file of the iOS project:

[assembly: ExportRenderer(typeof(WebView), typeof(Xamarin.Forms.Platform.iOS.WkWebViewRenderer))] 

But this just shrunk the page size:
enter image description here

Any help?

Sqlite best practice - single DB connection for app or open/close connection for each operation?

$
0
0

Hi,
I've seen various coding samples where people either open and hold a SqliteConnection for the life of the app and others were the SqliteConnection is opened and closed. The Sqlite documentation indicates that there is a SERIALIZED threading mode that makes sharing a connection between threads safe.
Does anyone have experience using that in Xamarin Forms? I'll have background threads updating the database at the same time as the UI threads.
Should I obtain SqliteConnection and open/close it with every operation or leave the SqliteConnection open the life of the app?

App localization (Best way)

$
0
0

Hi guys
I wonder, it there any pretty solution for localizing apps?

So, currently if we want to support several languages (for example En, Ru, Nl etc.) we will have to create 3 files (resx, json etc)
It's very well, if your company has got 3 native speakers for these languages, they will do all work.
But what should we don't have them? Yes, we will sent these files for translators. But there is a problem, they won't see the context of that texts. They will have just one file (Key-Value). It can cause some troubles with wrong translation, can't it?

Any ideas, approaches?

System.MissingMethodException - Default constructor not found for type System.Array

$
0
0

I was trying to release an app and after releasing to UWP and Android, I was crashing in Release or Ad-Hoc build on IOS when running on my iPad (release 12)
The app ran find in the Simulator and in Debug Mode.
I managed to start logging information and found a strange error (seemed that some code was being skipped on iOS). I worked around that issue and then bumped into another error (System.MissingMethodException - Default constructor not found for type System.Array)
Running out of options, I changed my Linking option from "Link Framework SDKs Only" , to "Don't Link".
Following this change the application ran without any issues.
Stranger still, when I switched back to Link SDKs, the ipa file size remained the same and the app now works.
This took a long time to track down. (I think I will be installing Hockey App to help with crash reports.)

Anyone else run into this?
Any ideas why linking options should make a difference?


For anyone else trying to log errors. here are some tips that might help.
I created a Logger class that creates a file using

var dir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
_logFileName = Path.Combine(dir, $"log.{DateTime.Now:s}.txt");

I then write messages using
File.AppendAllLines(_logFileName, message);

To get to the file on an iPad, I add the following to info.plist
<key>UIFileSharingEnabled</key>
<string>YES</string>

Then after I run the app, I sync with iTunes.
In iTunes, look for "File Sharing" and click on your app and you will see the logs that were saved.

Convert System.Drawing.Region to SKRegion

$
0
0

I am porting a windows desktop project that is using System.Drawing into SkiaSharp.
I have some uses of System.Drawing.Region, I need to convert it from and to SKRegion.. How to do that?

Note: I have tried using SkiaSharp.Views nuget which is very useful to convert to/from System.Drawing.Bitmap (for ex), but I could not find any equivallent windows desktop extension for SkRegion.

Custom Renderer Control does not appear until I navigate away then back to page on device.

$
0
0

Hey guy's, was following the admob tutorial and got everything working perfectly in the emulator, ads showed up perfectly. However, on my physical device, the ads don't show up at all unless I navigate away from the page then return. It's very strange and annoying, anyways my custom renderer code is below and I hope someone knows whats going on!

  • ` public class AdViewRenderer : ViewRenderer<AdControlView, AdView>
    {

     //Note you may want to adjust this, see further down.
        AdSize adSize = AdSize.SmartBanner;
        AdView adView;
        Location location;
    
    
    
        AdView CreateNativeAdControl()
         {
    
    
            var adUnitId = ((AdControlView)Element).AdUnitID;
            if (adView != null)
                return adView;
    
            adView = new AdView(Android.App.Application.Context);
            adView.AdSize = adSize;
            adView.AdUnitId = adUnitId;
            var adParams = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent);
    
            adView.LayoutParameters = adParams;
            var request = new AdRequest.Builder();
    
    
         adView.LoadAd(request.Build());
            return adView;
        }
    
     protected override void OnElementChanged(ElementChangedEventArgs<AdControlView> e)
     {
    
          base.OnElementChanged(e);
     if(Control == null)
            {
               CreateNativeAdControl();
               SetNativeControl(adView);
          }
    
    
       }
    
     public AdViewRenderer(Context context):base(context)
     {
    
     }
    
     }`
    

Not generating xaml.g.cs files

$
0
0

I've just updated an old PCL project to .NET Standard (2.0) and it has now stopped generating the xaml.g.cs files. Consequently none of the xaml pages compile, and it can't find any of the variables in the xaml.cs file that were declared in the xaml files. It also can't find InitializeComponent() in the xaml.cs files.

The name 'InitializeComponent' does not exist in the current context.

I've tried adding a new xaml file and it also doesn't generate the xaml.g.cs file, altho when I try the same thing in a newly created .NET Standard project it all works fine.

I've been playing around a bit with the .csprog file, trying to make it mimic the project that works, but that hasn't made any difference either.

Does anyone have any suggestions about what could be going wrong.

Where are the XAML designer tools?

$
0
0
Years have past ;-) not really but I think this question has been asked many Times' before.

The forms previewer crash all the time. It could be seen more of a compile:designer that breaks as soon as you start adding codebehind stuff.

We need a designer for Xaml not css? I think the web guys gonna stick to other tools anyways
The live previewer very nice idea, same thing doesn't work yet.

I just need BLEND with a Visual state manager. where is the backning from the Microsoft team that dream up stuff like the Blend tools :-)

Possible to share xaml snippets between pages?

$
0
0

Hi - is there any way to create a xaml snippet and use that snippet on several pages?

Sort of an "include" method or something similar?

Anybody found a way of doing this?

Thanks,

Can't build on android phone and getting the following errors.

$
0
0

I'm trying to compile my project on my android 8.1 phone but it doesn't build because of 2 errors.
I'm using Visual Studio Community 2017 version 15.8.7.
The project is using Xamarin.Forms version 2.5.0.280555.
I've downloaded all the android SDK's from 6.0 and up.
My PC is running on Windows 10 Pro.

ERROR 1:
Severity Code Description Project File Line Suppression State
Error Could not load file or assembly 'System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) FileName C:\Users\USER.nuget\packages\refit\4.6.30\build\netstandard1.4\refit.targets 29

ERROR 2:
Severity Code Description Project File Line Suppression State
Error The "ResolveLibraryProjectImports" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load assembly 'FileName, Version=0.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'FileName.dll'
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(String fullName)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Extract(DirectoryAssemblyResolver res, ICollection1 jars, ICollection1 resolvedResourceDirectories, ICollection1 resolvedAssetDirectories, ICollection1 resolvedEnvironments)
at Xamarin.Android.Tasks.ResolveLibraryProjectImports.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() FileName.Android

Failure has occurred while loading a type - App.xaml

$
0
0

Hello everybody,
I have a cross platform app that was perfectly working before last Visual Studio Update. After this update, the Components were no longer supported and I removed the "ComponentReference" related code in my .csproj files, as suggested by a Visual Studio warning message.
But now, when I build the Xamarin.Forms project, it instantly terminates getting the error message "Failure has occurred while loading a type" in App.xaml.
Here is my App.xaml:

<?xml version="1.0" encoding="utf-8"?>
<Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="RichEipt.App">
    <Application.Resources>
        <!-- Application resource dictionary -->
        <ResourceDictionary>
        </ResourceDictionary>
    </Application.Resources>
</Application>

And this is the stack trace:

Target BclBuildEnsureBindingRedirects:
Skipping target "BclBuildEnsureBindingRedirects" because all output files are up-to-date with respect to the input files.
Target ResolveAssemblyReferences:
A TargetFramework profile exclusion list will be generated.
Consider app.config remapping of assembly "Validation, Culture=neutral, PublicKeyToken=2fc06f0d701809a7" from Version "2.2.0.0" [] to Version "2.4.0.0" [/Users/marco/Richeipt/Richeipt_App/packages/Validation.2.4.18/lib/portable-net45+win8+wp8+wpa81/Validation.dll] to solve conflict and get rid of warning.
/Library/Frameworks/Mono.framework/Versions/4.8.1/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(1980,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file:
Done building target "ResolveAssemblyReferences" in project "RichEipt.csproj".
Target GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
Target XamlG:
Generating code behind for XAML files
App.xaml : error : Failure has occurred while loading a type.
Done building target "XamlG" in project "RichEipt.csproj" -- FAILED.

Done building project "RichEipt.csproj" -- FAILED.

Build FAILED.

I have no clue about what the problem could be and I can't find any thread related to this (hopefully silly) error.
Can anyone help on this?

Thank you
Simone

[Xamarin.Forms 2.2.0] Wrapping MasterDetailPage inside NavigationPage

$
0
0

Hey guys!

I'm trying to do something I thought was rather simple. Before 2.2.0 I had the following code :

var mainPage = new MasterDetailPage
{
    MasterBehavior = MasterBehavior.Popover,
    Master = menuContentPage,
    Detail = detailsContentPage
};
var navigationPage = new NavigationPage(mainPage);
Application.Current.MainPage = mainPage;

The way I reason about this code is "create a NavigationPage with its navigation stack's first child being a MasterDetailPage, so that I can later push other pages on top of the entire MasterDetailpage.". In 2.1.x it used to work fine, on UWP at least (did not test Android / iOS). However, in 2.2.0, the hamburger menu toggle is missing (while working just fine on Android). After no luck with Google, I decided to look inside Charles Petzold's book (great work with this one, by the way!), and found this :

The MasterDetailPage.Master and MasterDetailPage.Detail property elements are set to in-stances of MasterPage and DetailPage, respectively, but with a little difference: The Detail prop-erty is set to a NavigationPage, and the x:Arguments tags specify the DetailPage as the construc-tor argument. This is necessary to enable the user interface that lets the user switch between the mas-ter and detail pages on the Universal Windows Platform.

So I tried that, and indeed it works! However, by doing this, I loose the functionality of pushing new pages on top of the MDP. I need this pages to act and feel "modal", so the user shouldn't have any access to the side menu. I've seen it behaving sort-of right on Android if I push on the NavigationPage wrapper for the details page, in the sense that the drawer turns into a back button, and I could indeed disable the swipe gesture in that case, but it's a messy workaround, and besides, by doing it like this on UWP, both the hamburger toggle and back button show up, which is not what I want.

So my question to you guys is how can I achieve this behaviour? (if even possible)

Note that I need to support Android, iOS and UWP.

Thank you!

Simulatori IOS on visual studio 2017

$
0
0

I'm testing my APP made with xamarin.forms on IOS with a MAC connected remotely. in the visual studio the iphone 7, 8, x, xs simulators have disappeared.
the target is IOS10 ...
What could be the problem?


Printing From WebView Xamarin Forms

$
0
0

Hello guys,

I want to print a web view with the default printer functionalities on UWP

My UWP won't build with the .NET Native Toolchain

$
0
0

I'm trying to build a UWP application in release mode x86. The "Compile with .NET Native tool chain" is checked

I get the error - "The specified task executeable "ilc.exe" could not be run. The requested operation requires elevation."

I'm using Visual Studio 2017, Microsoft.NETCore.UniversalWindowsPlatform v6.1.9

Not sure what is going on. Please help :)

How can I add data picker inside Segmented Control

$
0
0

Hi,
I am finding difficult in adding data picker inside Segmented control .

Is there a code coverage tool available for Visual Studio Mac?

$
0
0

I'm writing unit tests for my code and I realized that I can't see code coverage. Now the problem is that every tool that I find is for Windows or it costs too much for me. Does anyone have a solution?

It's possible to add Tap gesture to the Entry?

$
0
0

Hi All,
As I wrote in the title, it's possible to add Tap gesture to the Entry?
This code works for Label but doesn't work for Entry:

var tapEntryRecognizer = new TapGestureRecognizer(); tapFocusEntryRecognizer.Tapped += async (s, e) => { Console.WriteLine("tapped"); }; tapEntry.GestureRecognizers.Add(tapFocusEntryRecognizer);

Viewing all 91519 articles
Browse latest View live


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