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

Error using JwtSecurityToken

$
0
0

Hi
I'm trying to use custom auth taken from the wonderful book written by adrian hall
https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure/chapter2/custom/

But I'm in trouble with the next code in IHttpActionResult Post([FromBody] User body)
.....
System.IdentityModel.Tokens.Jwt.JwtSecurityToken token = Microsoft.Azure.Mobile.Server.Login.AppServiceLoginHandler.CreateToken(
.....

I get an error "Reference to type JwtSecurityToken claims is defined in 'System.IdentityModel.Tokens.Jwt,, but it could not be found"
If I downgrade the nget System.IdentityModel.Tokens.Jwtback to 4.0.20622.1351 I can solve: but how can I solve if I want use the vers. 5.0 ??
Tnx


TargetFrameworkVersion I need V7.1 not v8

$
0
0

Hello

I am beginner Xamarin but I practice C # windowsforms for years

I installed only what connects Android 7.1 but I get this error

The $(TargetFrameworkVersion) for FormsViewGroup.dll (vv8.0) is greater than the $(TargetFrameworkVersion) for your project (v7.1). You need to increase the $(TargetFrameworkVersion) for your project.

The version 8 does not interest me I wish the version 7.1 as well on the emulator as on live player

My problem is that I can not find a trace of the v8 in the configuration of my project

How can I configure my project on version 7.1?

thanks in advance

ASMX service very slow on first call

$
0
0

I have an ASMX service. Proxy class uses SoapHttpClientProtocol Invoke().

The first request from my app is very slow (0.5-2 minutes). The next requests are fast (1 second). This is regardless of HTTPS or HTTP.

A packet sniffer shows that it takes 17 seconds from I call the first request, until my app sends the first packet.

Output window:

03-23 10:28:50.018 D/Mono ( 2358): Image addref Mono.Security[0xd1221ba0] -> Mono.Security.dll[0xd126ff00]: 2
03-23 10:28:50.018 D/Mono ( 2358): Prepared to set up assembly 'Mono.Security' (Mono.Security.dll)
03-23 10:28:50.018 D/Mono ( 2358): Assembly Mono.Security[0xd1221ba0] added to domain RootDomain, ref_count=1
03-23 10:28:50.019 D/Mono ( 2358): AOT: image 'Mono.Security.dll.so' not found: dlopen failed: library "/data/app/com.example.MyApp-1/lib/x86/libaot-Mono.Security.dll.so" not found
03-23 10:28:50.019 D/Mono ( 2358): AOT: image '/usr/local/lib/mono/aot-cache/x86/Mono.Security.dll.so' not found: dlopen failed: library "/data/app/com.example.MyApp-1/lib/x86/libaot-Mono.Security.dll.so" not found
03-23 10:28:50.020 D/Mono ( 2358): Config attempting to parse: 'Mono.Security.dll.config'.
03-23 10:28:50.020 D/Mono ( 2358): Config attempting to parse: '/usr/local/etc/mono/assemblies/Mono.Security/Mono.Security.config'.
03-23 10:28:50.020 D/Mono ( 2358): Assembly Ref addref System[0xe577af80] -> Mono.Security[0xd1221ba0]: 2
Loaded assembly: Mono.Security.dll [External]
03-23 10:28:50.020 D/Mono ( 2358): Assembly Ref addref Mono.Security[0xd1221ba0] -> mscorlib[0xea20a340]: 52
03-23 10:28:50.036 D/Mono ( 2358): Assembly Ref addref Mono.Android[0xe5779780] -> System[0xe577af80]: 14

By the way, when I use HttpWebRequest and manually write SOAP envelope and parse XML it is much faster even the first time (2-3 seconds). But much more work to maintain, so I rather not use this method.

Label position and text alignment

$
0
0

Hi,

I try to right align text under Label but can't find how do this. I try to make 3 label like this :

Label 1 | Label 2 | Label 3

Here is my layout

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="BasicForm.MainPage">
    <ContentPage.Content >

            <StackLayout Spacing = "0" Padding="10, 40, 10, 40" BackgroundColor="Green" Orientation="Horizontal" HorizontalOptions="FillAndExpand" VerticalOptions="Start">
                <Label x:Name="start" Font="Large" Text="t" HorizontalOptions="FillAndExpand" VerticalOptions="Center"></Label>
                <Label x:Name="middle" Font="Large" TextColor="Red" Text="e" HorizontalOptions="Center" VerticalOptions="Center"></Label>
                <Label x:Name="end" Font="Large" Text="st" HorizontalOptions="FillAndExpand" VerticalOptions="Center"></Label>
            </StackLayout>

    </ContentPage.Content>
</ContentPage>

Label 2 contain only one letter so it have to be on center of the screen. Label 1 is the start of the word (align right) and Label 3 the end of the word.

Any ideas for a workaround when sizing incorrect for Entry in ScrollView in Grid on UWP

$
0
0

I have a complex page layout that involves a Grid into which I dynamically insert other Layouts/Views. On iOS and Android, this works fine, but on UWP I hit a problem when inserting an Entry (nested in a ScrollView) that is bound to a non-Empty string. In that situation, the height of the Entry does not take into account the FontSize of the text in the Entry.

I've simplified the code down to the following, where an instance of BugUWPEntryBindingPageView gets pushed onto the navigation stack.
If the Entry is bound to ValueOne (initially a non-empty string) the height of the Entry is incorrect when the Entry is added to the Grid.
If the Entry is bound to ValueTwo (initially an empty string) the height of the Entry is correct.

This looks like a Xamarin.Forms bug to me (I'm using XF 2.4.0), but (other than always starting with an empty string and later setting the correct value in the ViewModel) has anybody got any ideas for a workaround? (I don't want to wait for Xamarin to release a fix before getting this particular page working as expected)

using Xamarin.Forms;

namespace ViewsUsingXamarinForms
{
    public class BugUWPEntryBindingViewModel
    {
        public BugUWPEntryBindingViewModel()
        {
            ValueTwo = string.Empty;
            ValueOne = "123";
        }

        public string ValueOne { get; set; }
        public string ValueTwo { get; set; }

    } // public class BugUWPEntryBindingViewModel

    public class BugUWPEntryBindingPageView : ContentPage
    {
        private static readonly BugUWPEntryBindingViewModel ViewModel = new BugUWPEntryBindingViewModel();

        private Grid _grid;

        protected override void OnAppearing()
        {
            _grid = new Grid
            {
                BackgroundColor = Color.White,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions = LayoutOptions.FillAndExpand,
                ColumnDefinitions = new ColumnDefinitionCollection
                {
                    new ColumnDefinition { Width = GridLength.Star },
                },
                RowDefinitions = new RowDefinitionCollection
                {
                    new RowDefinition {Height = GridLength.Auto },
                    new RowDefinition {Height = GridLength.Star }
                },
            };

            _grid.Children.Add(
                new Button
                {
                    Text = "Add/replace entries",
                    BackgroundColor = Color.Blue,
                    TextColor = Color.White,
                    Command = new Command(OnAddEntries)
                }, 0, 1, 0, 1);

            BindingContext = ViewModel;
            Content = _grid;
        }

        private void OnAddEntries()
        {
            Entry entry = new Entry
            {
                FontFamily = "Verdana", //DeviceWrapper.DefaultFontFamily,
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Entry)),
            };
            entry.SetBinding(
                Entry.TextProperty,
                new Binding(
                    nameof(BugUWPEntryBindingViewModel.ValueOne),
                    BindingMode.TwoWay,
                    null,
                    string.Empty));
            _grid.Children.Add(
                new ScrollView
                {
                    Content = new StackLayout
                    {
                        Children =
                        {
                            entry
                        }
                    }
                }, 0, 1, 1, 2);
        }
    }
}

How to place an Absolute Layout inside a Stack Layout

$
0
0

Hello there! So what I'm trying to accomplish is the following: I have a scrollview with a stack layout inside it, and I'd like to create multiple absolute layouts which each wrap around a group of elements, which would then be added into the stack layout. For the sake of clarification consider something like Instagram's homepage, where you have Posts composed of an Image, the User's Name on top of It, and the comments section beneath it. Ideally, I'd like to create those "post" objects and have them wrapped inside an absolute layout, which in turn would be stacked inside a stacklayout, which would be scrollable (inside a scroll view). Now, I'm not sure if the way I'm implementing it is the best way to do so, but any help would be appreciated.

Code looks something like this

`

    <StackLayout x:Name="StackLayout_Container"
                 HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
                 Spacing="10"
                 Padding="5"
                 ></StackLayout>

</ScrollView>`

I then create CardObjects as needed with each containing its own absolute layout, and later have them added to the StackLayout. This works, but for some reason the views inside the absolutelayout (images, labels ..etc) end up being too small and aren't positioned correctly, and the scrollview isn't scrollable. Any help is appreciated

ScrollView not updating when elements are changed on Android

$
0
0

I have a ContentPage, with a ScrollView that has a StackLayout with a couple of nested StackLayouts.

Essentially:

public class Widgets : ContentPage
{
    StackLayout layout;
    public Widgets()
    {
        layout = new StackLayout()
        {
            VerticalOptions = LayoutOptions.FillAndExpand,
            Orientation = StackOrientation.Vertical
        };

        var Widget = new Wiget();
        layout.Children.Add(Widget.Render());
        //Widget.Render() returns a StackLayout with some other UI elements, it also loads some items from the web and adds them to the stacklayout. 

        var Widget2 = new Wiget2(); //Same idea...
        layout.Children.Add(Widget2.Render());

        Content = new ScrollView()
        {
            HorizontalOptions = LayoutOptions.FillAndExpand,
            VerticalOptions = LayoutOptions.FillAndExpand,
            Content = layout
        };
    }
}

When the Widget class finishes loading the web items, and adds them to the stacklayout, the new elements are not rendered, in fact any change to the UI does not get rendered. The widgets display a Loading icon while the items are loading, this is displayed properly and the loading icon disappears when loading is complete, but the new elements do not show up.

This appears this when running on Android, the ScrollView and related Widget elements work properly on iOS. Admittedly I can only try Android on the emulator so not sure if it is an issue with it. I am using the built-in Android_Accelerated_Nougat with API version 25. (7.1.1)

iOS Binding Library in Xamarin Forms project

$
0
0

I have a binding library that works fine in a Xamarin iOS project, but if I try to use it in a Xamarin Forms project, the application crashes with a SIGSEGV every time as soon as the library is accessed.

Are there any special concerns to take into account when using a binding library with a Forms app?


Navigations like LinkedIn with Bottom Tabbar

$
0
0

How to make the navigations like LinkedInApp with Tabbar in every screen.
If I clicked on profile image the Content in the middle changing with back button in the top navigation bar.I have to achieve this in both Android and iOS using Xamarin.Forms



i'm facing an error while trying to install 'SidebarNavigation 2.0.0'

$
0
0

Hi all
I'm new to xamarin i was try to install SidebarNavigation 2.0.0 from nuget.org and I got this error message 'Could not install package 'SidebarNavigation 2.0.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.'
What is mean, how I can fix it
Thanks in advance

How to change Toolbar Background and Text Color ?

$
0
0

Hey,

i want to change the color from the Toolbar and the color from the Text in Toolbar too, can someone help me to do this?

At the moment i have a black default Background, but want to change it to green. Where i can set the color for the ContentPage Toolbar?

Greez Dahl

Has anyone managed to hide the Title/Status bar in xamarin forms UWP?

$
0
0

I have no trouble hiding the toolbar, but I want to have a fullscreen windowless app in UWP when I hit the fullscreen button and then go back to a windowed app with a title bar when I hit it again. It was easy in windows forms but I can't seem to figure it out for Xamarin Forms. Any suggestions?

Method Stub Creation

$
0
0

I am using Visual Studio 2017 v15.6.4, in the XAML file when I add markup that includes events how do I get the system to create the method stub in the code behind. I have tried alt-enter, ctrl ., none of them seem to work. Maybe not the correct place to ask this question, but I am hoping someone out there can tell me how to do it.

visual studio popup a message "the application is in break mode"

$
0
0

Can't deploy my code into my android device, with out any break points it replies "The application is in break mode" am using VS2017.
Thank you for your cooperation.

Cross platform solution for reminders

$
0
0

Greetings,

is there any way to show a notification at a defined date and time? It should also work even when the app has been killed or the device has been rebooted.

Right now I'm considering to use a web service to send push notifications to the device at a specific device but I'd like to use a local option for that. Has anyone ever implemented this or knows a cool NuGet?

Kind regards

Mario


Tabbedpage in XAML code

$
0
0

How to construct the following code in code-behind page in XAML, where we check to see if it is Android or iOS? If Android, no navigationbar:

public class MainPage : TabbedPage
{
        public MainPage()
        {
            Page itemsPage = null;

            switch (Device.RuntimePlatform)
            {
                case Device.iOS:
                    itemsPage = new NavigationPage(new ItemsPage())
                    {
                        Title = "Items"
                    };
                    break;
                default:
                    itemsPage = new ItemsPage()
                    {
                        Title = "Items"
                    };
                    break;
            }

            Children.Add(itemsPage);

            Title = Children[0].Title;
        }
}

Toolbar backbutton

$
0
0

I want to change the navigation of back button in toolbar. I have 3 pages main page, login page and profile page. After successful login it is navigated to profile page. Form profile page when back button is clicked it navigates back to login page, but i need to navigate to main page. Please do let me know how can I solve this.

Repair installation of Xamarin and dependencies

$
0
0

I've been struggling a complete morning with out of date and incompatible xamarin packages and version.

What do I need to do to recreate a stable environment?

The complete error log:
Attempting to gather dependency information for package 'Microsoft.Bcl.Build.1.0.14' with respect to project 'WeatherApp.Droid', targeting 'MonoAndroid,Version=v7.0'
Gathering dependency information took 1.58 sec
Attempting to resolve dependencies for package 'Microsoft.Bcl.Build.1.0.14' with DependencyBehavior 'Lowest'
One or more unresolved package dependency constraints detected in the existing packages.config file. All dependency constraints must be resolved to add or update packages. If these packages are being updated this message may be ignored, if not the following error(s) may be blocking the current package operation: 'Xamarin.Android.Support.v7.MediaRouter 24.2.1 constraint: Xamarin.Android.Support.v7.Palette (= 24.2.1)'
Resolving dependency information took 0 ms
Resolving actions to install package 'Microsoft.Bcl.Build.1.0.14'
Resolved actions to install package 'Microsoft.Bcl.Build.1.0.14'

Attempting to gather dependency information for package 'Microsoft.Bcl.Build.1.0.14' with respect to project 'WeatherApp.iOS', targeting 'Xamarin.iOS,Version=v1.0'
Gathering dependency information took 127.22 ms
Attempting to resolve dependencies for package 'Microsoft.Bcl.Build.1.0.14' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'Microsoft.Bcl.Build.1.0.14'
Resolved actions to install package 'Microsoft.Bcl.Build.1.0.14'

Attempting to gather dependency information for package 'Microsoft.Bcl.Build.1.0.14' with respect to project 'WeatherApp.Windows', targeting 'Windows,Version=v8.1'
Gathering dependency information took 124.95 ms
Attempting to resolve dependencies for package 'Microsoft.Bcl.Build.1.0.14' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'Microsoft.Bcl.Build.1.0.14'
Resolved actions to install package 'Microsoft.Bcl.Build.1.0.14'
Found package 'Microsoft.Bcl.Build 1.0.14' in 'C:\Users\Johannes\documents\visual studio 2015\Projects\WeatherApp\packages'.
Install failed. Rolling back...
Package 'Microsoft.Bcl.Build.1.0.14' does not exist in project 'WeatherApp.Droid'
Executing nuget actions took 22.29 ms
Could not install package 'Microsoft.Bcl.Build 1.0.14'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v7.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
========== Finished ==========
Time Elapsed: 00:00:05.4649957

Question around using Xamarin.Forms with Paypal.Forms

$
0
0

Q1) In order to use Paypal.Forms, ... should I assume I should go ahead to create a new app in the 'REST API apps' in Paypal website first?
Q2) Accorrding to this website 'https://github.com/AlejandroRuiz/PayPal.Forms', It shows how we can make a request for a single or a list of buying items. But, how about 'Profile sharing' and 'Obtain a Client Metadata ID'? I am not quite sure when to use this? Or why we need profile sharing or client MetaData? and what is the sequent? How to start?
Q3) Do I need to use OAuth for paypal.forms implementation?
Q4)Do I need to write any server side script to validate and capture the payment, and host it on a web hosting server?
Q5) How about the return URL upon the completion of the payment? .... If I have no hosting a website, what should I put for the return Url?

How to set height and width of LoadingPlaceholder in CachedImage of FFImageLoading in Xamarin.Forms?

$
0
0

I want to set height and width of LoadingPlaceholder in CachedImage of FFImageLoading in Xamarin.Forms.

I have tried by following way but the GIF image use full size and shows big. I want to make it 64px as it's current size.

xaml file
Namespace: xmlns:ff="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"

<ff:CachedImage Source="image.png" Aspect="AspectFill" 
        LoadingPlaceholder="Spinner64px.gif" 
        WidthRequest="375"
        HeightRequest="375">
</ff:CachedImage>

Can you please suggest me how to show original size of gif image or set height and width of it?

Image:

Viewing all 58056 articles
Browse latest View live