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

DisplayAlert - Detect Cancel button is clicked or not

$
0
0

Hi,

I am using DisplayAlert to show the successful message after complete the form.

DisplayAlert ("Success", "Form Saved", "Ok");

I need to go back to the previous page when Ok button is tapped.

Navigation.PopAsync ();

How to detect whether the Ok button is clicked or not? I know that we can detect if we have both Ok and Cancel button. In my requirement, Ok button is enough.

Need help on this!


OneSignal Push notification

$
0
0

Hi,
I wanted to do push notification using OneSignal. I wanted to send notification to some usergroups. But I am confused if am sending to specific tags from server, how will the notification will be sent to specific usergroup rights. How will I check whether to show the notification for this user or not. I am keeping my usergroup rights in the device but how will i compare with tags in the device.. I am totally confused with this stage from beginning. Any hint to do this.

thanks in advance

ListView layer issue

$
0
0

Hello,

I created a custom element to display a loading bar looking like the "indeterminate" bar in the following image

XAML

<?xml version="1.0" encoding="UTF-8"?>
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
    x:Class="CustomViews.LoadingBarView" HeightRequest="{StaticResource Thickness}" VerticalOptions="Start" BackgroundColor="Transparent">
    <ContentView.Resources>
        <ResourceDictionary>
            <x:Double x:Key="Thickness">5</x:Double>

            <Style x:Key="LoadingBar" TargetType="StackLayout">
                <Setter Property="HeightRequest" Value="{StaticResource Thickness}" />
                <Setter Property="BackgroundColor" Value="Blue" />
                <Setter Property="VerticalOptions" Value="Start"/>
                <Setter Property="HorizontalOptions" Value="FillAndExpand"/>
            </Style>

            <Style x:Key="LoadingParticle" TargetType="BoxView">
                <Setter Property="HeightRequest" Value="{StaticResource Thickness}" />
                <Setter Property="WidthRequest" Value="10" />
                <Setter Property="HorizontalOptions" Value="Start"/>
                <Setter Property="Opacity" Value="0.6"/>
                <Setter Property="Color" Value="White"/>
            </Style>
        </ResourceDictionary>
    </ContentView.Resources>
    <ContentView.Content>

        <StackLayout Style="{StaticResource LoadingBar}" x:Name="LoadingBar" AutomationId="LoadingBar" VerticalOptions="Center">
            <BoxView Grid.Row="0" Style="{StaticResource LoadingParticle}" x:Name="Particle" AutomationId="LoadingParticle"/>
        </StackLayout>

    </ContentView.Content>
</ContentView>

CS

public partial class LoadingBarView : ContentView
{
    public LoadingBarView()
    {
        InitializeComponent();
        this.TranslationY = -5;
    }

    /// <summary>
    /// Animate the loading bar.
    /// </summary>
    public void Animate()
    {
        this.IsVisible = true;

        var animation = new Animation(v => Particle.TranslationX = v, 0, this.Width);
        animation.Commit(this, "LoadingAnimation", 16, 1000, Easing.SinIn, 
                    (v, c) => Particle.TranslationX = this.Width, () => true);

        this.TranslateTo(0, 0);
    }

    /// <summary>
    /// Stop and hide the loading bar.
    /// </summary>
    public void Stop()
    {
        this.TranslateTo(0, -5).ContinueWith(t => {
            this.IsVisible = false;
            if (IsRunnung)
                Particle.AbortAnimation("LoadingAnimation");
        });
    }

    public bool IsRunnung => Particle.AnimationIsRunning("LoadingAnimation");
}

I use it by placing it on the same layer as the content of my pages but is causes them to render empty if the loading bar has been used on the page or another one. Here is an usage example:

<ContentPage.Content>
    <Grid>
        <ListView ItemsSource="{Binding Model.AccessKeys}" CachingStrategy="RecycleElement" Grid.Row="0"
            IsRefreshing="{Binding IsBusy}" IsPullToRefreshEnabled="true" RefreshCommand="{Binding RefreshCommand}"/>
        <custom:LoadingBarView x:Name="LoadingBar" Grid.Row="0"/>
    </Grid>
</ContentPage.Content>

Any idea how to prevent the page from rendering empty ? (it only occurs on android)
Thanks for any help

How to make rotation infinite?

$
0
0

Hi,

I want to create loading indicator. I need to rotate image infinitely. I tried to add animation like that:
indicatorBottom.RotateTo(-360, 2000);

It animates image once. How to make it infinitely?

Thanks in advance.

Xamarin.Forms.Maps custom renderer working on iOS and not on Android ...

$
0
0

I have spent WAY TOO MUCH time on this issue..... PLEASE HELP!

My usage scenario is as follows:
Get data from the database
Clear the map if there are points - Seems easier than trying to manage data points / pins ??
Plot the new points with custom marker images

I based by implementation on the example here but it only has a single point and does not manipulate the points at all...

So I am adding about 200 pins to a map and that works ...

The iOS custom renderer seems to function properly....

The user needs to be able to filter the "pins"

When I want to remove a pin from the map it seems there is no way to clear the pins from the map in the PCL / .NET Standard library code base ???

So I tried to remove the pins like so ....
MainOverviewMap.Pins.Clear();
and

 foreach (var pin in MainOverviewMap.Pins.ToList())
 {
       MainOverviewMap.Pins.Remove(pin);
 }

The problem is that when you add a pin in the PCL / .NET Standard library code the "CreateMarker" fires in the custom renderer on Android and I can set the custom icon.

When you remove a pin in the PCL / .NET Standard library code nothing fires in the Android custom renderer code as far as I can tell to remove the pin / marker from the google map.

I am using Xamarin.Forms.Maps - 2.5.1.444934
VS 2017 - 4.7.02556
Android - Api 23 (HAXM simulator)

Any advice you can offer on what I may be doing wrong or how to accomplish this would be greatly appreciated

Xamarin has lost references to Mono seemingly

$
0
0

I was having many errors with my Xamarin project not being able to recognize the Android namespace and read that the solution was to delete the contents of the /bin folder and let it re-build from scratch.

I did that and now I am getting the error here:

The only thing I've found is that a small number of other people have had this error and there is no solution in their threads. Under references the path to Mono.Android.dll is correct (C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v8.0\Mono.Android.dll), and the file exists. I can remove the reference and re-add it and will still see the same error.

Does anyone know how I can fix this and get back to my previous set of mysterious Xamarin errors?

How to create popup navigation in xamarin forms?

$
0
0

I use Navigation.PushModalAsync(nextpage); but this is open bottom to top but i want to pop the page, how can i implement can you help me .

OkHttp install leads to compilation error - Xamarin Forms

$
0
0

Hello all,

I'm working on a calculator app in Xamarin Forms, Android and iOS, with a survey function to report the user's location to the nearest degree of latitude and longitude and send it to a web service if proper permissions are given. I could send an HttpWebRequest without issue, but in trying to implement a way to use https, I installed OkHttp. On compliation of the Android version, this throws the Lokio/AsyncTimeout error referenced on this GitHub thread(the one about OneSignal) and I can't find a reference to either OneSignal or OkHttp in my project, and after rolling back my changes this error still occurs. How can I remove OneSignal or OkHttp, whichever would be best? Thank you.


Button difference in Android on Xamarin.Forms VS template for Windows and Mac

$
0
0

I find this a bit strange, but in the current version of VS for Windows and Mac there is one difference in the template that I can't figure out.

I want the button to be without the shadow on Android. If I create the project on the Mac, I only need to add renderer that inherits from Xamarin.Forms.Platform.Android.ButtonRenderer and BackgroundColor to the button. However, on project created on Windows this doesn't work.

What is very odd is that if I open the project created on the Mac on Windows it works the same on the Mac, so there is something different in Android project itself, not in the environment.

But I can't figure out what, and I would need it for one project that is already created on Windows. My best guess would be that it is something in styles.xml, but I can't see any important difference.

Does someone know something about this?

Xamarin forms Compile App for ChromeBook ChromeOS

$
0
0

Hello Team,

Regarding my issue. I am using Google Chrome OS version 56.0.2924.110 Platform 9000.910 Firmware Google_Veyron_minnie.6588.237.0 The Google Chrome Book is touch screen. Made by Asus.

Any application I compile in Xamarin Forms PCL, does not run on my Google ChromeBook (Google-Chrome-OS).

I would like to know If anyone had any success in writing and compiling applications that successfully run on Google Chrome OS, using Xamarin Forms. If so, what type of settings did you use while building the application. I cant seem to find anything regarding this in google search. I greatly appreciate any feedback input thoughts on how to compile for Chrome OS.

P.S I have compiled pure native Java Application using Android Studio, and this runs fine on Google Chrome OS. But using Xamarin Forms PCL does not run on Google Chrome OS.

Thank you!

Android crash: Master detail page orientation change

$
0
0

I have implemented the master detail page into my app but whenever I rotate in an Android, the app crashes. However, on the iOS it doesn't crash. What can be the cause of it? How to fix it?

What are the best way to check the iOS app without any apple device?

$
0
0

I only have a windows laptop and android mobile. but I haven't any other iOS device. So, how can test our Xamarin Form app for an iOS device?. Also, give me the solution.

How can we add Footer in a listview as we add Header?

$
0
0

I am not able to get Footer repetedly in a listview Why? .I want Footer repetedly in a Listview as Header in Xamarin forms

Xamarin Forms Custom Fonts CrossPlateform

$
0
0

Hi,

I'm following the Fonts Tutorial proposed by Xamarin to have a custom downloaded fonts over each plateform. However, I got lot of problems and I also try to find a way to do some things but whitout find how to make it works.

First, take a look at the tutorial and begin at the concerning part. Using a Custom Font


iOS:

It says that we have to add the font.tff into the Resources folder.
Then, we have to do something with the Info.plist, but what? I'm not sure to understand what I have to do.

Androïd:

Xamarin.Forms for Android does not currently expose the ability to set the font to a custom font file, so custom renderers are required.

CustomLabelRenderer.cs

public class CustomLabelRenderer : LabelRenderer
{
    protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
    {
        base.OnElementChanged(e);

        System.Diagnostics.Debug.WriteLine(Forms.Context.ApplicationContext.Assets, e.NewElement.StyleId + ".ttf");

        if (!string.IsNullOrEmpty(e.NewElement?.StyleId))
        {
            var font = Typeface.CreateFromAsset(Forms.Context.ApplicationContext.Assets, e.NewElement.StyleId + ".ttf");
            Control.Typeface = font;
        }
    }
}

According to the documentation, the OnElementChanged() would be called, however, it doesn't. Debug.WriteLine() doesn't display anything. Why?

WinPhone 8.1:

We have to add the font file to the /Assets/Fonts/ folder in the application project and set the Build Action:Content. Once realized, Xamarin.Forms for Windows Phone can reference a custom font that has been added to the project by following a specific naming standard. However, the Font doesn't take place on the view, the font stays standard, why?


At the moment, after lot of searches, lot of try... Nothing..

I'm trying to add DIN Condensed Bold font

My XAML layout:

<ContentPage.Content>
 <AbsoluteLayout BackgroundColor="#235A5E">
  <!-- Menu -->
  <AbsoluteLayout x:Name="Menu" BackgroundColor="#2F767B"
                  AbsoluteLayout.LayoutBounds="0,0,1,0.1"
                  AbsoluteLayout.LayoutFlags="All">
    <Label x:Name="label" Text="Connection" TextColor="White" FontSize="30" VerticalOptions="Center" HorizontalOptions="Center"
           AbsoluteLayout.LayoutBounds="0.5, 0, 0.8, 1"
           AbsoluteLayout.LayoutFlags="All"/>
    <Button x:Name="ConnectionButton" BackgroundColor="Transparent" BorderColor="Transparent"
           AbsoluteLayout.LayoutBounds="1, 0.5, 0.2, 1"
           AbsoluteLayout.LayoutFlags="All"/>
  </AbsoluteLayout>
 </AbsoluteLayout>
</ContentPage.Content>

So the FontFamily property of the Label can be set like that

<Label Text="Hello World !" FontFamily="DIN Condensed Bold"

But, as told in the tutorial, for the WinPhone by example, it has to be done by another way so, I try to change the FontFamily by the C# part.

public partial class MyPage : ContentPage
{
    public string FontFamily { get; set; }

    public MyPage()
    {
        InitializeComponent();

        label.FontFamily = Device.OnPlatform(
            iOS: "DIN Condensed Bold",
            Android: "DIN Condensed Bold",
            WinPhone: @"Assets\Fonts\DINCondensedBold.ttf#DIN Condensed Bold"
        );
    }
}

Which doesn't works too ! I also saw something interesting for me about the XAML part. I want (f the FontFamily works one day..) to have a defintion we makes me able to just edit one field string to set all Label's FontFamily of my page.

<ContentPage.Resources>
  <ResourceDictionary>

  </ResourceDictionary>
</ContentPage.Resources>

I saw that I might be able to define a FontFamily for all of the Label of MyPage.xaml, how does it works?

I'm also a newbie about MVVM but I tried to bind my public string FontFamily { get; set; } to the Label defined in the xaml <Label Text="Hello World !" FontFamily="{Binding FontFamily}"/> but one more time, without success..

I'm totaly stuck... Who can help either to make works the tutorial or explain me each things I mentioned after the tutorial. Thank for help !

listview header and footer

$
0
0

Hi
Where can I find an example how to use header and footer in new listview? Not mvvm...
Thanks


Frame in xamarin forms

$
0
0

Frame in xamarin forms is not working all of a sudden.

DLToolkit.Forms.Controls.FlowListView is not working in android but it's working ios app

$
0
0

I am getting this issue while using DLToolkit.Forms.Controls.FlowListView:

AOT: image '/storage/emulated/0/Android/data/com.bizx.infinite.bizx/files/.override/DLToolkit.Forms.Controls.FlowListView.dll.so' not found: dlopen failed: library "/data/app/com.bizx.infinite.bizx-1/lib/arm/libaot-DLToolkit.Forms.Controls.FlowListView.dll.so" not found

[Mono] AOT: image '/usr/local/lib/mono/aot-cache/arm/DLToolkit.Forms.Controls.FlowListView.dll.so' not found: dlopen failed:

Earlier it was working fine all of a sudden today it's not working what should i do?

Xamarin Forms - How to change Cursor colour of Editor

$
0
0

My target is to show a Log File (with Larger Content String) in my App. For this, I tried showing it in a Label; but unfortunately the label doesn't ready to show a VERY LARGER CONTENT. Hence the page is blank. It work very well for a smaller content though.

So, I tried showing it using EDITOR . Is works very well. Loading larger content into it in a fraction of second.

I don't want EDITOR to be editable. Hence I used Focused, UnFocused properties to handle it. ** WORKS WELL**.

Problem:

The problem here is,

THE CURSOR IN EDITOR IS SHOWN TO THE USER. I DONT WANT USER TO KNOW THAT IT IS EDITABLE.
I NEED TO MAKE CURSOR COLOR TO TRANSPARENT.

Quick Help will be very helpful. Thanks a lot.

How to implement FLIR thermal camera AAR library

$
0
0

I'm trying to use the FLIR thermal camera library in a xamarin.forms project. I've created a binding for the AAR and have added the DLL to my xamarin.forms Android project's references. The projects compile and run without errors. The next step is to create a device. I've followed the FLIR Android Java example. Here's my class (C#):

using Application = Android.App.Application;
using Device = Com.Flir.Flironesdk.Device;
using Exception = System.Exception;
using FlirUsbDevice = Com.Flir.Flironesdk.FlirUsbDevice;
using Frame = Com.Flir.Flironesdk.Frame;
using FrameProcessor = Com.Flir.Flironesdk.FrameProcessor;
using LoadedFrame = Com.Flir.Flironesdk.LoadedFrame;
using RenderedImage = Com.Flir.Flironesdk.RenderedImage;
using SimulatedDevice = Com.Flir.Flironesdk.SimulatedDevice;

public partial class MainMenu : ContentPage, Device.IDelegate, FrameProcessor.IDelegate, Device.IStreamDelegate, Device.IPowerUpdateDelegate 
{
    private Device flirDevice;

    public MainMenu()
    {
        try
        {
            Device.StartDiscovery(Application.Context, this);
        }
        catch (IllegalStateException exception)
        {
            // it's okay if we've already started discovery
        }
        catch (SecurityException securityException)
        {
            // 
        }
    }

    public void OnDeviceConnected(Device device)
    {
        flirDevice = device;
        flirDevice.SetPowerUpdateDelegate(this);
        flirDevice.StartFrameStream(this);
    }
}

The StartDiscovery call completes without error, and no IllegalStateException or SecurityException, but then I get the following error -

Unhandled Exception: Java.Lang.NullPointerException: Attempt to invoke interface method 'void com.flir.flironesdk.Device$Delegate.onDeviceConnected(com.flir.flironesdk.Device)' on a null object reference

I'm guessing that the interface can't see my OnDeviceConnected method. There are no compiler errors, and I have implemented the OnDeviceConnected method, which can be seen in my code above. Do I have to somehow manually assign the onDeviceConnected delegate to my method, or does the problem lie elsewhere? Has anyone come across this problem using AARs with xamarin.forms? Any help much appreciated.

[Prism] getting null value on SelectedItemChanged event of HorizontalList

$
0
0

Hi, Need help in Prism's EventToCommandBehavior.

I am getting null data on SelectedItemChanged for Xamarin.Forms.Plugin.HorizontalList instead of selected Item data.

Here is code
1) XAML

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms"
prism:ViewModelLocator.AutowireViewModel="True"
x:Class="grabeats.Views.ImageList"
xmlns:control="clr-namespace:HorizontalList;assembly=HorizontalList"
xmlns:ffimage="clr-namespace:FFImageLoading.Forms;assembly=FFImageLoading.Forms"

xmlns:converters="clr-namespace:grabeats.Converters;assembly=grabeats"
xmlns:behaviors="clr-namespace:Prism.Behaviors;assembly=Prism.Forms">

<ContentPage.Content>
<Grid >
<Grid.RowDefinitions >
<RowDefinition Height="100" />
</Grid.RowDefinitions>
<control:HorizontalList
ItemsSource="{Binding ImageList}"
ListOrientation="Horizontal" Grid.Row="0"
Padding="2,2,2,2"

>
<control:HorizontalList.Behaviors>
<behaviors:EventToCommandBehavior EventName="SelectedItemChanged" 
Command="{Binding SelectImageListCommand}"
EventArgsConverter="{converters:SelectedItemChangedCommandEventArgsConverter}"/>
</control:HorizontalList.Behaviors>

<control:HorizontalList.ItemTemplate >
<DataTemplate>

<ffimage:CachedImage
Margin="2,2,2,2"
Aspect="Fill"
Source="{Binding imageUrl}"
LoadingPlaceholder="Loadingsome.gif">

</ffimage:CachedImage>

</DataTemplate>
</control:HorizontalList.ItemTemplate>
</control:HorizontalList>

</Grid>
</ContentPage.Content>
</ContentPage>

2) ViewModel:

using grabeats.Model;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Navigation;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace grabeats.ViewModels
{
public class ImageListViewModel : BindableBase, INavigationAware
{
private readonly INavigationService _navigationService;

private ObservableCollection<imageList> _imageList;
public ObservableCollection<imageList> ImageList
{
get { return _imageList; }
set { SetProperty(ref _imageList, value); }
}

public ImageListViewModel(INavigationService navigationService)
{
_navigationService = navigationService;

ImageList = new ObservableCollection<imageList>()
{
new imageList() {imageUrl = "https://in.bmscdn.com/…/baaghi-2-et00053840-22-02-2017-08-5…", Name = "1"},
new imageList() {imageUrl = "https://in.bmscdn.com/…/blackmail-hindi-et00069346-17-01-20…", Name = "2"},
new imageList() {imageUrl = "https://in.bmscdn.com/…/a-quiet-place-et00065343-17-11-2017…", Name = "3"},
new imageList() {imageUrl = "https://in.bmscdn.com/…/hichki-et00054008-27-02-2017-06-27-…", Name = "4"}
};
}

private DelegateCommand<imageList> _selImageList;

public DelegateCommand<imageList> SelectImageListCommand => _selImageList ?? (_selImageList = new DelegateCommand<imageList>(ShowImageListSelectedDetails));

private void ShowImageListSelectedDetails(imageList paramData)
{
var parameters = new NavigationParameters
{
{ "customerId", paramData.Name }
};

//await _navigationService.NavigateAsync("CustomerDetailsPage", parameters);
}

public void OnNavigatedFrom(NavigationParameters parameters)
{

}

public void OnNavigatedTo(NavigationParameters parameters)
{

}

public void OnNavigatingTo(NavigationParameters parameters)
{
//if (parameters.ContainsKey("title"))
// Title = (string)parameters["title"];
}
}
}

3) Converter:

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using grabeats.ViewModels;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace grabeats.Converters
{
public class SelectedItemChangedCommandEventArgsConverter : IValueConverter, IMarkupExtension
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var itemSelectedEventArgs = value as SelectedItemChangedEventArgs;
if (itemSelectedEventArgs == null)
{
throw new ArgumentException("Expected value to be of type ItemTappedEventArgs", nameof(value));
}
return itemSelectedEventArgs.SelectedItem;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}

public object ProvideValue(IServiceProvider serviceProvider)
{
return this;
}
}
}

I am able to invoke ShowImageListSelectedDetails method but with null paramter instead of selected Item.

Please assist

Viewing all 58056 articles
Browse latest View live


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