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

Anyone successfully passed cookies to WkWebView?

$
0
0

I have been working on a Custom WebView that on iOS uses the native WkWebView instead of the default.
My pain is that passing cookies to it from a HttpClient does not always sent those cookies on first request.
The intention is that the user, already being logged in using a HttpClient, opens a page showing the webpage of our service. By reusing the cookies, the user does not need to authenticate again. But by using the WkWebView, I sometimes end up on the loginpage, as a result of cookies not being passed properly.

This is my iOS Custom Renderer for the WebView:

public class CustomWebViewRenderer : ViewRenderer<CustomWebView, WKWebView>
{
    protected override async void OnElementChanged(ElementChangedEventArgs<CustomWebView> e)
    {
        base.OnElementChanged(e);

        if (e.NewElement != null)
        {
            if (Control == null)
            {
                var config = new WKWebViewConfiguration();

                var jCookies = Appl.FlurlClient.Cookies.Values;

                NSHttpCookie[] nsHttpCookies = jCookies.Where(c => c != null).Select(c => new NSHttpCookie(c)).ToArray();

                foreach (var c in nsHttpCookies)
                {
                    await config.WebsiteDataStore.HttpCookieStore.SetCookieAsync(c);
                }

                var webView = new WKWebView(Frame, config);
                SetNativeControl(webView);
            }
            Control.LoadRequest(new NSUrlRequest(new NSUrl(Element.Uri)));
        }
    }
}

Xamarin.Forms TimePicker with 15 minutes Intervals?

$
0
0

Hi!
is there a way to get a TimePicker in Xamarin.forms which has only 0,15,30,45 minutes to choose?

I tried using custom renderer in Android with something like this:

`class MyTimePickerRenderer : TimePickerRenderer
{

   protected override void OnModelChanged(Xamarin.Forms.VisualElement oldModel, Xamarin.Forms.VisualElement newModel)
   {
        base.OnModelChanged(oldModel, newModel);          

        Android.Widget.TimePicker tpdi =  (Android.Widget.TimePicker)Control;

        var numberPicker = FindMinuteNumberPicker(tpdi as ViewGroup);
        if (numberPicker != null)
        {
            numberPicker.MinValue = 0;
            numberPicker.MaxValue = 5;
            numberPicker.SetDisplayedValues(new String[] { "00", "15", "30", "45" });
        }


    }
    public NumberPicker FindMinuteNumberPicker(ViewGroup viewGroup)
    {
        for (var i = 0; i < viewGroup.ChildCount; i++)
        {
            var child = viewGroup.GetChildAt(i);
            var numberPicker = child as NumberPicker;
            if (numberPicker != null)
            {
                if (numberPicker.MaxValue == 59)
                {
                    return numberPicker;
                }
            }


            var childViewGroup = child as ViewGroup;
            if (childViewGroup != null)
            {
                var childResult = FindMinuteNumberPicker(childViewGroup);
                if (childResult != null)
                    return childResult;
            }
        }

        return null;
    }
}`

bust it didn't work...

hope you have any ideas ...

FloKo

Xamarin.Forms TimePicker with 15 minutes Intervals?

$
0
0

how to pass min interval in the Xamarin Forms TimePicker.

I had solution for the renderer iOS:

[assembly: ExportRenderer(typeof(TimePicker), typeof(TimePickerRenderers))]
namespace Anjep_Toolbox.MobileApp.iOS.Renderer
{
public class TimePickerRenderers : TimePickerRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);
if(e.NewElement != null)
{
var timePicker = (UIDatePicker)Control.InputView;
timePicker.Locale = new NSLocale("no_nb");
timePicker.MinuteInterval = new nint(15);
}

  //if (Control != null)
  //{
  //  Control.Text = DateTime.Now.ToString("HH:mm");
  //}
}

}
}

but not found any working solution for the android platform.

so guys kindly let me know if you have a solution.

Please help me!

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.

ListView inside CarouselView scroll vertical is almost impossible.

$
0
0

I have a collection of listviews inside a horizontal CarouselView. When im trying to scroll vertically through the listview in focus, if make any tiny movement horizontally, the carousels horizontal scrolling "takes over" and makes scrolling vertically almost impossible. Anyway i can "prioritize" the listviews scrolling?

Hope it makes sense :)

How to get audio file locations?

$
0
0

I am trying to get locations of audio files in Xamarin.Forms. I am currently using resources to play audio file, I put there myself, but want to search the phone for these files and save in a List with its locations?

Xamarin.Forms.Maps repeated authentication error

$
0
0

Hi all,
I am having some trouble integrating google maps with the Xamarin maps SDK, I have already contacted google on the matter but they said they can only help if it is part of the google maps SDK itself. The reason why I am using Xamarin.Maps over the google play service maps are because I am building this application to work cross-platform and I doubt that the google play services maps will work on both iOS and Android (Not building for Windows Phones).

The problem I am having is that I am getting the same authentication error every single time causing the maps to not display any of the data itself. I followed the guide on Xamarin.Forms Map Initialization but still have nothing.
I have checked the API key many times and even created new ones just encase I did the setup wrong on the google console end. As well as this I have also checked all my authentication information to the same degree, I am certain the data I have entered isn't wrong. Can anyone provide any insight to if I have entered the data in the wrong manner or if there is simply something deeper going on here!
~Thanks - Alex

Right now I am debugging on android so I just want to get it working there first

The Error (API key removed):
11-07 16:18:31.173 E/Google Maps Android API( 6862): Authorization failure. Please see developers.google/maps/documentation/android-api/start for how to correctly set up the map.
11-07 16:18:31.176 E/Google Maps Android API( 6862): In the Google Developer Console (console.developers.google)
11-07 16:18:31.176 E/Google Maps Android API( 6862): Ensure that the "Google Maps Android API v2" is enabled.
11-07 16:18:31.176 E/Google Maps Android API( 6862): Ensure that the following Android Key exists:
11-07 16:18:31.176 E/Google Maps Android API( 6862): API Key: AIzaSyBpwq(The full API key is here just censored for the forums)
11-07 16:18:31.176 E/Google Maps Android API( 6862): Android Application (;): 42:DF:8F:89:DE:8A:48:25:34:(Full cert is here but censored for forms);com.IFDS.carapp

NullReferenceException on MainActivity > OnCreate() > LoadApplication(new App());

$
0
0

Hi, I'm getting a NullReferenceException at this line:
LoadApplication(new App()); in my main activity.
What I was working on was adding a Compat Theme in order to get this badge plugin working, following this and this blogpost.

[Activity(Label = "ServiceApp.Droid", 
MainLauncher = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]

    public class MainActivity : FormsAppCompatActivity {
    protected override void OnCreate(Bundle bundle) {
            FormsAppCompatActivity.ToolbarResource = Resource.Layout.Toolbar;
            FormsAppCompatActivity.TabLayoutResource = Resource.Layout.Tabbar;
            base.OnCreate(bundle);
        [...]
            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());
   } 
[...]
}

Resources looking like this:
Resources/values/color.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <color name="primary">#FFDD00</color>
  <color name="primaryDark">#FFDD00</color>
  <color name="primaryLight">#FFECB3</color>
  <color name="accent">#9E9E9E</color>
  <color name="primaryText">#212121</color>
  <color name="secondaryText">#757575</color>
  <color name="window_background">#FFFFFF</color>
  <color name="icons">#212121</color>
  <color name="divider">#BDBDBD</color>
</resources>

Resources/values/styles.xml:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
  <style name="MyTheme" parent="MyTheme.Base">
  </style>
  <style name="MyTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primaryDark</item>
    <item name="colorAccent">@color/accent</item>
    <item name="android:windowBackground">@color/window_background</item>
    <item name="windowActionModeOverlay">true</item>
  </style>
</resources>

Resources/values-v21/styles.xml:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <style name="MyTheme" parent="MyTheme.Base">

    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowAllowEnterTransitionOverlap">true</item>
    <item name="android:windowAllowReturnTransitionOverlap">true</item>
    <item name="android:windowSharedElementEnterTransition">@android:transition/move</item>
    <item name="android:windowSharedElementExitTransition">@android:transition/move</item>
  </style>
</resources>

Also
Resources/layout/Tabbar.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.TabLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/sliding_tabs"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:tabIndicatorColor="@android:color/white"
    app:tabGravity="fill"
    app:tabMode="fixed" />

And
Resources/layout/Toolbar.xml:

<?xml version="1.0" encoding="UTF-8"?>
<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:layout_scrollFlags="scroll|enterAlways" />

Am I missing something about the themes? Or is there a way to get more info abot the exception?
I followed it by stepping through the LoadApplication(new App()); and it seemed it crashed on the very last step.

Thanks for your help,
regards, Martin


Have to clean/rebuild project every time

$
0
0

Hi,

I've just started to use Xamarin Forms and every time I want to run an iOS application in the simulator I have to clean/rebuild the solution. If I don't then it appears to still compile, but always runs the previously cleaned/built version... Am I missing something? From Googling it seems I'm the only one with this issue! Tried 2 separate PCs and a fresh install of everything. Also tried going back a few versions of Xamarin Forms but no luck

It's incredibly annoying and rendering it almost unusable.

Thanks!

VS 2019 16.1.6
Xamarin Forms 4.1.0.581479

Master Detail on Android (Prism) - Accessing Camera via Detail disables Hamburger Menu button

$
0
0

HI,

I have a MasterDetail Page with a button to access the Camera or Gallery on several of the Detail Pages. I'm noticing that upon exiting the Camera/Gallery the Hamburger Menu button is disabled and the only way to access the Menu is by swiping from the left of the screen.

Has anyone come across this behaviour and found a workaround?

Thanks in advance

UWP Could not find windows runtime 'Microsoft.UI.Xaml.Controls.XamlControlsResources'

$
0
0

Hey all,
I just updated my xamarin forms version from 4.2 to 4.3.

When I try to run my UWP application, I get a splash screen and I get the following exception

$exception {"Could not find Windows Runtime type 'Microsoft.UI.Xaml.Controls.XamlControlsResources'.":"Microsoft.UI.Xaml.Controls.XamlControlsResources"} System.TypeLoadException

in my uwp's app.xaml.cs Xamarin.Forms.Forms.Init(e)
I went through the process of cleaning my solution, reinstalled the nugut packages, and deleting my bin and object folders. Still no luck.

After some research, this is from the Microsoft.UI.Xaml.dll which should be packaged in UWP by default.

Has anyone experience this issue before?

HorizontalTextAlignment not working after 4.3.0.908675 update for android

$
0
0

After updating Xamarin.Forms to 4.3.0.908675 (or greater) from 4.2.0.910310, HorizontalTextAlignment = TextAlignment.Center no longer works for Entry views on Android. Labels and Pickers apparently, are not affected.

Any Ideas why?

how to set title of navigation bar to center?

$
0
0

in xamarin forms how to set title of navigation bar to center?

I need to port and Xamarin.Android app to IOS... What Mac should I get

$
0
0

Hello,

I am not a Mac user, but I need to purchase a Mac so I can do IOS development on Xamarin.

I am looking for recommendations on which Mac is best for this job.

Also, what are your recommendations for IOS phones? I just need the phone for dev purposes.

Thanks in advance!

-d

During an iOS Build it stops with a Droid error MSB4094.

$
0
0

My setup: Visual Studio 2019 - current updates; Xamarin Forms - Latest build.

I am doing an iOS build (Build->Build Solution with the settings AppStore; iPhone; MyApp.iOS) and it seems to hang/stop with the message:
3>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(104,10): error MSB4094: "obj\Release\90\MyApp.Droid.dll;obj\Release\90\MyApp.Droid.dll" is an invalid value for the "OutputAssembly" parameter of the "Csc" task. Multiple items cannot be passed into a parameter of type "Microsoft.Build.Framework.ITaskItem".

Questions:
1) If I am doing an iOS build, why is it messing with Droid?
2) How do I fix the error? I have tried clean and deleting the bin and obj files. I saw a suggestion to "uncheck Activate ClickOnce security settings” but I can't find such settings.


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

Allow iOS PageRenderer to render as custom UIViewController

$
0
0

Summary

Update the PageRenderer class so that it can render as a custom UIViewController instead of just a UIViewController

API Changes

I propose two ways of doing this.

Make PagerRenderer generic, so the user can set the page like so:

CustomPageRenderer : PageRenderer

or, add a SetNativeControl() function so the user can set what control to render as, such as:

var myPage = new MyCustomUIViewController();
SetNativeControl(myPage);

Intended Use Case

There are a lot of libraries out there that are just classes that inherent from UIViewController, we can't really use them since PageRenderer will only render a Xamarin forms page as a UIViewController.

Best way to create non full screen popup?

$
0
0

Hi,

I am trying to create a menu that will take over 80% of the screen.
This is a customer request and I can't use the master details.
I tried few popup lib but non of them gave me a solution for non full screen popup.

  • the white area will be a list control.

Thanks,

Ady.

Error Building iOS project on Xamarin Forms

$
0
0

Hi,

I am trying to build my iOS in my Xamarin Forms using Visual Studio for Windows but getting this error..

Kindly help...

Thanks,
Jassim

Direction for renderer

$
0
0

[Posted in University but board seemed a bit slow]

I am looking for advice on producing a window to render output into. I want to build game frames but I am unsure of the limitations Xamarin would have for this kind of function.

Another option is building an application in Unity if I can then somehow place my game inside a Xamarin application.

Viewing all 91519 articles
Browse latest View live


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