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

Facebook and Google login in Xamarin.Form

$
0
0

Hello, my name is Daniel, I'm from Uruguay and I'm currently working on my final year project. It is a Cross-Platform application for Android and iOS. At this moment we are in an advanced stage of development, in which we are trying to incorporate advanced functionalities with my partner Diego. One of them is to be able to enter the app by logging in via Google or Facebook. For this we find a lot of information in google and in the forum but it is not adapted to the project or it is old. What we find always applies to the android project and not to the pcl. We want from our xaml page to be able to enter as google or facebook users.
We are currently working on .Net Standard and Android SDK v8.1
Could someone help us or provide information?
Thank you.


Using WebView for showing SSRS reports (Can it mimic another browser)

$
0
0

I am using a WebView to display a reports rendered from SSRS (SQL Server Reporting Services).
SSRS supports Edge, ie, Safari, Chrome and Firefox.
On UWP the pages render since on UWP WebView is using an Edge renderer.

But on IOS and Android nothing shows since it is using Webkit (or whatever on Android).

I would hope that since Xamarin is a Microsoft company and since the only way to show SSRS reports on mobile devices is via HTML, the 2 divisions would talk to each other and make Xamarin a good platform for displaying SSRS reports.

Just wondering if there is a way around this. Can I make the WebView mimic another browser? Are there plans to update WebView to use Safari on iOS and Chrome on Android. The default Android browser also works with SSRS.

For now, my fallback is to request the reports as PDFs and display then in a Syncfusion PDF control. Not the greatest solution because the report becomes static and can't take advantage of SSRS mobile features.

Thanks

HotReload LiveReload LiveXaml [Mac] [Windows] [nuget package] [opensource]

Can I use google cloud speech API in my xamarin.forms application?

$
0
0

Is it possible to integrate google cloud speech API in Xamarin.forms apps? If yes, Could you share steps or sample examples to achieve the same?

Thanks in advance!

Animation when changing MainPage of the application

$
0
0

I am using a MasterDetail template and I also have a login page. In my app when I am logged out I have set:

MainPage = new LoginPage();

When I will successfully log in I am just changing MainPage to MasterDetailNavigation like this:

MainPage = new MasterDetailNavigation();

However, there is no animation (page transition) when I am changing MainPage. How can I add it? It would be great to have i.e. the same animation which is when we are doing:

Navigation.PushAsync(new SomePage())

How can I achieve this animation?

DataTrigger work with Converter seems have BUG!!!

$
0
0

Requirement Description:

I'd like to change the source of a image by using "Data Trigger" , but when I use it with "Converter" , it doesn't work as expected.

Code:

CustomImage

public class CustomImage : Image
    {

        public CustomImage()
        {
            PropertyChanged += OnPropertyChanged;
        }

        private void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Source")
            {
                var fileSource = (Source as FileImageSource);
            }
        }
    }

Converter

public class IconSourceConverter : IValueConverter
{

    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (parameter != null)
        {
            string par = parameter as string;
            if (par == "Selected")
            {
                return "image_one.png";
            }
            else
            {
                return "image_one_selected.png";
            }
        }
        else
        {
            return "image_one.png";
        }
    }

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

    private enum ConverterParameter
    {
        NoSelected, Selected

    }
}

XamlCodeOne:

<control:CustomImage  WidthRequest="16"   >
                <control:CustomImage.Triggers>

                    <DataTrigger TargetType="control:CustomImage" Binding="{Binding IsVisible}" Value="False">
                   <Setter Property="Source" Value="{Binding PageType, Converter={StaticResource PageTypeToIconSource} , ConverterParameter='Selected' }" />
                    </DataTrigger>

                    <DataTrigger TargetType="control:CustomImage" Binding="{Binding IsVisible}" Value="True">
                                      <Setter Property="Source" Value="{Binding PageType, Converter={StaticResource PageTypeToIconSource} , ConverterParameter='NoSelected' }" />
                    </DataTrigger>

                </control:CustomImage.Triggers>
            </control:CustomImage>

XamlCodeTwo:

    <control:CustomImage  WidthRequest="16"   >
                    <control:CustomImage.Triggers>

                        <DataTrigger TargetType="control:CustomImage" Binding="{Binding IsVisible}" Value="False">
                            <Setter Property="Source" Value="image_one.png" />
                        </DataTrigger>

                        <DataTrigger TargetType="control:CustomImage" Binding="{Binding IsVisible}" Value="True">
                            <Setter Property="Source" Value="image_one_selected.png" />
                        </DataTrigger>

                    </control:CustomImage.Triggers>
                </control:CustomImage>

Result:

When I use XamlCodeTwo , it works well . But when I use XamlCodeOne , it doesn't work as expected and it toggles "OnPropertyChanged"(in CustomImage) several times . As I know , it should only be toggled when the value of DataTrigger change.

Question:

Why I use XamlCodeOne can not work and why it toggles "OnPropertyChanged" (in CustomImage) several times?

Firebase device token on Xamarin.Forms

$
0
0

I asked this question 17 hours ago on stackoverflow but sadly no one replied.

I have a Xamarin.Forms project and I'm using the firebase messaging platform to provide push notifications to my app. The last step that is stopping me from publishing the app is the lack of _FirebaseInstanceId _Nuget for xamarin.forms which seems to exist only for xamarin.android. The reason behind why it is so important for my project is getting the cloud messaging token. From what I've seen throughout internet forums it wasn't covered clearly what to do in this situation.

The notifications in my app work in an unusual way. The user chooses one of around 30 options, and then depending on his choice he receives appropriate push notification. So I've written a script that sends his choice to the firebase database and that is where his token is required so a javascript server connected to firebase could send him the push.

I hope I made it clear, and that that the solution wasn't covered previously on this forum. I'm still a beginner so a detailed solution or some suggestions would be really appreciated.

Custom renderer for Frame problem with shadow

$
0
0

Hi I made a custom render for frames because I'd like to control the shadow the problem is that it doesn't seem to workwith corner radius. this is how it looks now:

And my code for the renderer:

    public class MaterialFrameRenderer : FrameRenderer
        {
            public override void Draw(CGRect rect)
            {
                base.Draw(rect);

                // Update shadow to match better material design standards of elevation
                Layer.CornerRadius = 25f;
                Layer.BorderWidth = 0.1f;
                Layer.BorderColor = UIColor.LightGray.CGColor;
                Layer.ShadowRadius = 2.0f;
                Layer.ShadowColor = UIColor.Gray.CGColor;
                Layer.ShadowOffset = new CGSize(2, 2);
                Layer.ShadowOpacity = 0.80f;
                Layer.ShadowPath = UIBezierPath.FromRect(Layer.Bounds).CGPath;
                Layer.MasksToBounds = false;

            }
        }

I's ther some way to fix this, I would like the shadows to follow the rounded corners?

Best regards!
/magnus


ObservableCollection.AddRange()

$
0
0

If your Models expose an ObservableCollection, and you are adding lots of elements, you don't want this adding to fire a UI event every time.

You can use this ObservableCollection which only notifies the UI to update after all the elements are updated when AddRange is used:

public class ObservableCollectionFast<T> : ObservableCollection<T>
{
    public ObservableCollectionFast()  : base()   {   }

    public ObservableCollectionFast(IEnumerable<T> collection)  : base(collection)   {    }

    public ObservableCollectionFast(List<T> list)   : base(list)  {        }

    public void AddRange(IEnumerable<T> range)
    {
        foreach (var item in range)
        {
            Items.Add(item);
        }

        this.OnPropertyChanged(new PropertyChangedEventArgs("Count"));
        this.OnPropertyChanged(new PropertyChangedEventArgs("Item[]"));
        this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
    }

    public void Reset(IEnumerable<T> range)
    {
        this.Items.Clear();

        AddRange(range);
    }
}

How to select multiple images from gallery for android and IOS device and how to show it in the UI?

$
0
0

Same thread found here. But the answer is not complete.

Android part multiple image selection is working with that code, but didn't tell how to show the selected images in UI?

For IOS suggesting to install ELCImagePicker, but that Nuget is not available in Nuget store.

So anybody please suggest a solution for this feature?

Using Multiple Properties in Relative Layout Constraint Expressions on XAML

$
0
0

i want to use Height and Y property-

RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToView, ElementName=BtnAllRegion, Property=Height+Y, Factor=1, Constant=10}"

Trying to update packages, getting an error that the package has no compatible assembly references

$
0
0

I recently updated my Xamarin build tools for an older project. I decided to go ahead and try to install the latest package updates as well. When trying to update those packages I get the following error:

Could not install package 'EntityFramework 6.2.0'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v9.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.

I've tried changing my build target to API 28, 27, 25, and 21 as other posts suggested this helped some people. I've also uninstalled and reinstalled Visual Studio for Mac. This didn't make a difference for me. What else should I look at or try to get this working?

I'm working off of a Mac running the latest version of OSX.

Write to contacts on Xamarin.Forms

$
0
0

Hi,
I'm trying to write contact information into their respective address books. I've seen examples on reading contacts (still haven't managed to get it to work, none of the examples compile, have to spend hours resolving bugs to get it to work!) but is there anything out there to write to contacts?
From the AddressbookSample (https://github.com/softsan/AddressbookSample) , Xamarin.Contacts does not work. Xamarin.Mobile does not compile.
Is there any way?

Listview Item Animation and Delay

$
0
0

Hi there. I'm having trouble getting each item in a ListView to show up at separate times(like half a second apart each), similar to Google+ where each item animates in separately. I have a ScaleTo animation on the ViewCell itself but they still all appear at the same time. I've also monkeyed around with Task.Delay() but might be placing it in the incorrect location. Anyone have any guidance on the issue?

How to Load cache Image in offline in xamarin forms?

$
0
0

The issue occurs in all 3 platforms:

I am downloading an image and stored in the cache(default option for an image source "CachingEnabled = true"), and I have set the time span to 1 day.

On Loading, the page in offline the image is not displayed. whereas if I open the page in online it seems the image is downloaded and shown

Initially, I am downloading and saving as follows

webImage.Source = new UriImageSource
{
Uri = new Uri("Some Http image"),
CachingEnabled = true,
CacheValidity=new TimeSpan(1,0,0,0)
};

In the new page, I am using the following to show the image

newImage.Source = new UriImageSource
{
Uri = new Uri("Some Http image"),
}

In Offline, An empty page has displayed the image is not loaded. I have a question is whether the image is cached or not.

My question here is ** Has the image is cached? If so how to load the cached image in offline.**


Property Setter set multiple times - as many times as a bound subview mentioning it is opened.

$
0
0

Hi guys, I have found an issue....

I have a viewmodel with a ToSection property on it. Both Getter and setter etc. the Viewmodel is bound to my Main View. In my main view I have the command bound that opens a new subview that has the ToSection property mentioned in the xaml - this property is not used by anything else. I set the subview bindingcontext to 'this' - being the viewmodel and I'm pusing it onto the nav stack as follows:

                ToSection = null; // Reset To Section Picker.
                await parent.Navigator.PushAsync(
                    new WmsJobItemsToView
                    {
                        BindingContext = this,
                        Title = string.Format("{0} ({1})", e as string, Items.Where(o => o.Pending > 0).Sum(o => o.Pending))
                    });

However, everytime I press the button to open the subview and then set the ToSection property its setter is being called as many times as I've opened the subview - like it isn't releasing the first one when it is popped off the stack? What am I missing?

Why are those OnPlatform lines deprecated?

$
0
0

Hey there.

<OnPlatform x:TypeArguments="Thickness"
iOS="10"
Android="10"/>

is deprecated. As far as I know this should be used:

        <OnPlatform x:TypeArguments="Thickness">
            <On Platform="iOS">10</On>
            <On Platform="Android">10</On>
        </OnPlatform>

Same here. This is obsolete:

Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0);

instead a switch case similar to this should be used:

            int tVal;
            switch(Device.RuntimePlatform)
            {
                case Device.iOS:
                    tVal = 10;
                    break;

                default:
                    tVal = 10;
                    break;

            }
            Padding = new Thickness(0, tVal, 0, 0);

And I don´t understand why. The deprecated/obsolete way is shorter. Is this performance related or something else??

ViewCell and TranslateTo animation

$
0
0
Hi,

I would like to consume the Appearing event of a ViewCell inside a Listview so that when an element is being loaded, I can do some little nice animations such as loading it from left to right inside the Listview.

I can use TranslateTo, Fade and Scale for other Views such as Image but I am really struggling to do the same for a ViewCell inside a Listview.

Thanks

Tapping on Entry in ListView doesn't select the ListView row

$
0
0

I have a Label and an Entry in a ListView, however, when I tap any given Entry in the ListView, it does not select the ListView row that contains that tapped Entry. When I tap a Label, the selected ListView row is correctly changed. Is there a known workaround for this? I need the selected ListView row to change to the row containing the Entry that receives focus.

Xamarin Android crashing after loading splash_screen

$
0
0

I dont know why has been crashing , can i help you resolve issue? thanks

using Android.App;
using Android.Content.PM;
using Android.Views;
using Android.OS;
using Android.Util;
using FormApp.Helpers;
using Acr.UserDialogs;
using FFImageLoading.Transformations;
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
using AToolbar = Android.Support.V7.Widget.Toolbar;

namespace FormApp.Droid
{
[Activity(Label = "FormApp.Droid",
Icon = "@drawable/icon",
MainLauncher = true,
Theme = "@style/MainTheme",
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation,
NoHistory = true
)
]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
private static MainActivity _this;
public static AToolbar ToolBar { get; private set; }

    public static View RootFindViewById<T>(int id) where T : View
    {
        return _this.FindViewById<T>(id);
    }
    public MainActivity()
    {
        _this = this;
        Android.Support.V7.App.AppCompatDelegate.CompatVectorFromResourcesEnabled = true;
    }

    protected override void OnCreate(Bundle bundle)
    {
        TabLayoutResource = Resource.Layout.Tabbar;
        ToolbarResource = Resource.Layout.Toolbar;
        base.OnCreate(bundle);

        Rg.Plugins.Popup.Popup.Init(this, bundle);
        Xamarin.Forms.Forms.Init(this, bundle);
        UserDialogs.Init(this);
        FFImageLoading.Forms.Platform.CachedImageRenderer.Init(true);          
        var ignore = new CircleTransformation();

        RequestedOrientation = Xamarin.Forms.Device.Idiom == Xamarin.Forms.TargetIdiom.Phone ? ScreenOrientation.SensorPortrait : ScreenOrientation.SensorLandscape;
        MakeStatusBarTranslucent(true);
        LoadApplication(new App());
        Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);

    }

    public override bool OnCreateOptionsMenu(IMenu menu)
    {
        ToolBar = FindViewById<AToolbar>(Resource.Id.toolbar);
        return base.OnCreateOptionsMenu(menu);
    }


    public void OnTranslucentStatusRequest(StatusBarHelper helper, bool makeTranslucent)
    {
        MakeStatusBarTranslucent(makeTranslucent);
    }

    private void MakeStatusBarTranslucent(bool makeTranslucent)
    {
        if (makeTranslucent)
        {
            SetStatusBarColor(Android.Graphics.Color.Transparent);

            if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                Window.DecorView.SystemUiVisibility = (StatusBarVisibility)(SystemUiFlags.LayoutFullscreen | SystemUiFlags.LayoutStable);
            }
            else
            {
                using (var value = new TypedValue())
                {
                    if (Theme.ResolveAttribute(Resource.Attribute.colorPrimaryDark, value, true))
                    {
                        var color = new Android.Graphics.Color(value.Data);
                        SetStatusBarColor(color);
                    }
                }

                if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
                {
                    Window.DecorView.SystemUiVisibility = StatusBarVisibility.Visible;
                }
            }
        }
    }
}

}

Viewing all 91519 articles
Browse latest View live


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