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

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!


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

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

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?

Appropriate an iOS distribution - certificates, profiles, ...

$
0
0

Hi all,

Context:
I have the task of putting into production an application made by a tier, which will be called TA to update an application made historically by the company CB. TA has recoded the entire application, so it is more like the old, but I want to release the version under the guise of an update to not lose the thousands of users of the application. It remains the same application. My problem is that I can't take ownership of the signature entities and make Visual Studio detect signing certificates.

Actual config:
Certificate
Provisionning Profile
App ID
Archive Visual Studio

I have test with XCode, and XCode in Auto Sign add CB in the Signing Certificate, but, this certificate not exist today and it is not linked with this App ID.

Today I am completely helpless and I really have no idea how to do it. I spent 2 days, so I passed my dead line. If a charitable soul could yell me, I thanked him for it.

Thanks for your help.

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.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;

    }


}`

Custom base App Class

$
0
0

Hello all,

is there any way to derive the App class from a custom base class (of course that inherits from Xamarin.Forms.Application)?

I'm using visual studio and the autogenerated code in App.xaml.g.cs always refer to a global::Xamarin.Forms.Application no matter what I try to do?

Any advice?

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?

Using the Minimum Width for CollectionView

$
0
0

I have a CollectionView which I want to use the minimum necessary width. The containing Grid has the following ColumnDefinitions:
<Grid.ColumnDefinitions><ColumnDefinition Width="Auto"/><ColumnDefinition Width="*"/></Grid.ColumnDefinitions>
And the code for the CollectionView is as follows:

<d:CollectionView.ItemsSource>

1
2
3
4
5
6
7
8
9
10
11
12

</d:CollectionView.ItemsSource>
<CollectionView.ItemTemplate>

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

Viewing all 91519 articles
Browse latest View live


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