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

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.

ListView Item not selecting for the second time

$
0
0

Hi,
I'm using a listview in my application. When I select an item in hte listview its got freezed and not selecting for the second time. Is there any way to overcome this problem.If so please let me know.

Thanks,
sunil

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:

Customize Frame for only top left and bottom left corner in iOS?

$
0
0

Hi,

I've been trying to customize the frame with only top left and bottom left corner in iOS. I tried below code but its not working:
var rect = new CGRect(0,0,
UIBezierPath mPath = UIBezierPath.FromRoundedRect(this.Layer.Bounds, (UIRectCorner.TopLeft | UIRectCorner.BottomLeft),new SizeF(7,7));
CAShapeLayer maskLayer = new CAShapeLayer();
maskLayer.Frame = this.Layer.Bounds;
maskLayer.BackgroundColor = UIColor.Red.CGColor;
maskLayer.Path = mPath.CGPath;
this.Layer.Mask = maskLayer;

thanks again!!!

How to create a bindable view property inside a custom control

$
0
0

Hi guys,

I am trying to create a view that can contain another view but for unknown reason, I get weird behaviours!
This is what I have so far:

CustomView.xaml:

<?xml version="1.0" encoding="UTF-8"?>
<Grid xmlns="http://xamarin.com/schemas/2014/forms" 
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
      x:Class="AppTest.CustomView"
      HorizontalOptions="FillAndExpand"
      VerticalOptions="FillAndExpand"
      BackgroundColor="Aqua">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="1*" />
        <ColumnDefinition Width="1*" />
        <ColumnDefinition Width="1*" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="1*" />
        <RowDefinition Height="1*" />
        <RowDefinition Height="1*" />
    </Grid.RowDefinitions>

    <Label Grid.Column="0"
           Grid.Row="0"
           Grid.ColumnSpan="3"
           BackgroundColor="Chartreuse"
           Text="fdtyu7osrtjsrdytj"/>
    <ContentView x:Name="ViewContent"
                 Grid.Column="1"
                 Grid.Row="1"
                 HorizontalOptions="FillAndExpand"
                 VerticalOptions="FillAndExpand"
                 BackgroundColor="Coral"/>
</Grid>

CustomView.xaml.cs:

using System.Diagnostics;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace AppTest
{
    [ContentProperty(nameof(Content))]
    [XamlCompilation(XamlCompilationOptions.Skip)]
    public partial class CustomView : Grid
    {
        public CustomView()
        {
            Debug.WriteLine(nameof(InitializeComponent) + " started!");
            InitializeComponent();
            Debug.WriteLine(nameof(InitializeComponent) + " ended");
        }

        #region Content (Bindable Xamarin.Forms.View)

        /// <summary>
        /// Manages the binding of the <see cref="Content"/> property
        /// </summary>
        public static readonly BindableProperty ContentProperty
            = BindableProperty.Create(propertyName: nameof(Content)
                                    , returnType: typeof(Xamarin.Forms.View)
                                    , declaringType: typeof(CustomView)
                                    , defaultBindingMode: BindingMode.OneWay
                                    , propertyChanged: Content_PropertyChanged
                                    );

        public Xamarin.Forms.View Content { get => (Xamarin.Forms.View)GetValue(ContentProperty); set => SetValue(ContentProperty, value); }

        private static void Content_PropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            var control = (CustomView)bindable;
            var value = (View)newValue;

            if (control.ViewContent == null) Debug.WriteLine("ViewContent null!");
            if (ReferenceEquals(newValue, control)) Debug.WriteLine("New value is myself!!!!");
            if (newValue is Label label)
            {
                Debug.WriteLine("Added label with text: " + label.Text);
                if (label.Text.Equals("abc")) control.ViewContent.Content = (View)newValue;
            }
        }

        #endregion Content (Bindable Xamarin.Forms.View)
    }
}

CustomPage.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"
             x:Class="AppTest.CustomPage"
             xmlns:local="clr-namespace:AppTest">
    <local:CustomView x:Name="view">
        <Label Text="abc"/>
    </local:CustomView>
</ContentPage>

That's it. The app just launches a CustomPage.
I have a bunch of weird behavior when launching the windows emulator API 19.
Depending on the XamlCompilationOptions, I get different behaviours but always an Aqua coloured page with no labels as a final result :

  • For Skip:

    [0:] InitializeComponent started!
    [0:] ViewContent null!
    [0:] Added label with text: fdtyu7osrtjsrdytj
    [0:] ViewContent null!
    [0:] InitializeComponent ended
    [0:] Added label with text: abc

  • For Compile:

    [0:] InitializeComponent started!
    [0:] Added label with text: fdtyu7osrtjsrdytj
    [0:] InitializeComponent ended
    [0:] Added label with text: abc

I can't get my mind around it! It should basically say InitializeComponent started=>ended then Added label with text: abc.
The project settings are: .Net Standard 1.4 core library, Xamarin.Forms nuget v2.5.0.280555, Xamarin.Android.Support nuget v25.4.0.2, Windows emulator for android.
Can anyone reproduce this behaviour and explain this to me or have an idea, please?

Cheers,

G.


Implemement the number of tap required on a image, label and button

$
0
0

Can you any one please help me on this? I want implement the number of taps required on image or label in mvvm xamarin.forms?

Thanks in advance.

Table is not created

$
0
0

Hi

I'm using SQLite as a local database for my mobile application (Android); by using a SQLiteAsyncConnection I'm trying to create a new table, but it it's not working. No exception is raised, the code seems to execute just right, but the table is not created.

A sample of the code:
How the connection is created:

        public SQLiteAsyncConnection GetAsyncConnection()
        {
            try
            {
                var path = GetDatabaseFileLocation();

                var conn = new SQLiteAsyncConnection(path, false);

                return conn;
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }

            return null;
        }

        public string GetDatabaseFileLocation()
        {
            var sqliteFilename = "my_database.db3";
            string documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); // Documents folder
            var path = Path.Combine(documentsPath, sqliteFilename);
            return path;
        }

The method to create the table:

        public void CreateTable()
        {
            var asyncConnection = DependencyService.Get<ISQLite>().GetAsyncConnection();

            // This does not work
            asyncConnection.CreateTableAsync<MyModel>();

            // This does not work either
            //asyncConnection.GetConnection().CreateTable<MyModel>();
        }

None of the above statements seem to work ...

Anyone know what is going on?

How Xamarin.Forms handle encrypted app images to prevent resource extracting?

$
0
0

Currently ListView etc with image cells, we just supply image location, and Xamarin.Forms takes over and even recycle(?) the list items to display.

If images are encrypted, simply supply the image location won't work, and load binary beforehand may work, but with a list of 100s of items, will be a big or even deadly problem for the app.

So, anyone has a better idea how to deal with encrypted images?

Thanks a lot.

Unable to find a version of 'Xamarin.Forms' that is compatible with 'Xamarin.Android.Support.v4 23.3

$
0
0

I just created a Xamarin Forms project on Windows 10 in Xamarin Studio (updated to latest stable version), and I did a NuGet update on solution:

Looking for updates for 'Xamarin.Android.Support.v4'...
Updating 'Xamarin.Android.Support.v4' from version '23.0.1.3' to '23.3.0' in project 'MyApp.Droid'.
Updating 'Xamarin.Android.Support.v4 23.0.1.3' to 'Xamarin.Android.Support.v4 23.3.0' failed. Unable to find a version of 'Xamarin.Forms' that is compatible with 'Xamarin.Android.Support.v4 23.3.0'.

The Android project has default settings, I didn't change anything.

I'm a bit surprised this didn't work right off the bat....

how to know version of Xamarin Forms

$
0
0

I just installed community edition of the latest Visual studio with Xamarin. When I click Help->About I can see in the installed products that Xamarin is 4.0.x version. How do I know which version of Xamarin Forms am I using? And are Xamarin Forms upgraded independently? I was assuming that everything is from one installer.

Xamarin.Forms Android 8 API

$
0
0

Hi,
How do I use SetJustificationMode(JUSTIFICATION_MODE_INTER_WORD) in custom renderer for Label in my Android Project? I am using Visual Studio 15.5, downloaded SDK for API 26 Level, Target Framework: Android 8.0 Oreo, Target Android Version: Use Compile using SDK Version.
Specifically, in my custom renderer, I set
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
{
TextView tv = (TextView)Control;
tv.SetJustificationMode(JUSTIFICATION_MODE_INTER_WORD);
}
but Control.SetJustificationMode gives the following error.

'TextView' does not contain a definition for 'SetJustificationMode' and no extension method 'SetJustificationMode' accepting a first argument of type 'TextView' could be found (are you missing a using directive or an assembly reference?)

Gesture not updating its status as completed

$
0
0

I have a PanGestureRecognizer in my custom view. For the PanUpdated event handler, I have a function that does some stuff when the gesture is running and then something else when the gesture is completed. However, sometimes the gesture never gets to its completed state.
Any ideas?

Here's what I have...

        class ImageContainer : ContentView
        {

            public ImageContainer()
            {
                PanGestureRecognizer panGesture = new PanGestureRecognizer();
                panGesture.PanUpdated += OnPanUpdated;
                GestureRecognizers.Add(panGesture);
            }


            void OnPanUpdated(object sender, PanUpdatedEventArgs e)
            {
                switch(e.StatusType)
                {
                            case GestureStatus.Started:
                                // do some stuff
                                break;  
                    case GestureStatus.Running:
                    // do more stuff
                                break;
                            case GestureStatus.Completed:
                                // sometimes this does not get called!
                                break;
                }
            }
        }

Troubleshooting "too many open files" exception in iOS version of xamarin.forms app

$
0
0

We develop apps for iOS and Android using xamarin.forms. In appcenter, it turns out that one of our apps sporadically crashes in iOS with an error: "System.IO.IOException: Too many open files".

We've been googling on what causes this issue. We checked all our code, and we made sure (as far as we can find) that all filestreams are properly closed and disposed after usage. We also found that the garbage collector of iOS can be too late in collecting the streams, so we added a manual GC.Collect() call in the methods using filestreams.

However, the issue still seems to appear. Is there a way we can monitor if any file handles are not being closed, so we can find out why this error still occurs?

Some info that might be relevant for troubleshooting suggestions:

  • We're using Xamarin.Forms
  • We're using Visual studio 2017 on Windows PC
  • We have a mac connection in Visual studio to be able to build and debug the iOS version of our app

The full stacktrace of the crash:

System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) <0x105032c20 + 0x005c8> in :0 System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean isAsync, System.Boolean anonymous) <0x105032b70 + 0x0008f> in :0 System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.IO.IsolatedStorage.IsolatedStorageFile isf) <0x10503beb0 + 0x00057> in :0 System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.IsolatedStorage.IsolatedStorageFile isf) <0x10503c000 + 0x00067> in :0 IsolatedStorageFile.OpenFile (System.String path, System.IO.FileMode mode) Deserializer+<>c.b__1_0 () Task1[TResult].InnerInvoke ()
Task.Execute ()
ExceptionDispatchInfo.Throw ()
TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task)
TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task)
TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task)
ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () Application+d__69.MoveNext ()

Can we make a cross platform app for cab application like Ola and Uber?

$
0
0

If yes, then which type of libraries we add to it?

What version of Xamarin.Forms should I use

$
0
0

Hi!

I want to create a Xamarin.Forms app that will target as many devices as possible, targeting UWP, Android and iOS.
I was wondering which Xamarin.Forms version I should use.
I'm willing to compromise and provide no support for OSs or API levels with a low market share, especially if the minimal XF version that targets them contains critical fixes & features.

Is there a list that compares all XF versions and the API levels and OS versions they can target?

How can we fetch photos on our app from instagram or facebook?

$
0
0

Is this possible in Xamarin.forms?

Is there a way to get XAML binding intellisense in a separate ContentView file used in a ListView?

$
0
0

I have a ListView with this item template:

<ListView.ItemTemplate>
  <DataTemplate>
    <ViewCell>
      <views:ProjectListEntry />
    </ViewCell>
  </DataTemplate>
</ListView.ItemTemplate>

ProjectListEntry is fairly complex and is used in another ListView, so I have it in its own file. I've set it up like this:

<ContentView
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    ...
    BindingContext="{x:Static helpers:DesignTimeData.ProjectListEntryVm}">

As you can see, to get Intellisense, I tried to set BindingContext to a static member on the DesignTimeData class. This works fine for my Pages (where I replace the BindingContext at runtime), but for ContentViews used in ListViews, the ContentView's BindingContext seems to be inherited (from the ViewCell, I guess). This means that the explicit BindingContext on my ContentView will actually override the BindingContext set on the ViewCell by the ListView, and all my list elements will reflect the static design-time data at runtime. But if I remove the BindingContext, I get no intellisense for the members I bind to inside the ContentView file.

Is there a simple way to get Intellisense for bindings in a ContentView like this? (As mentioned, I can't inline the ContentView in the ListView definition, because the ContentView is fairly complex and used in several lists. I also can't use some kind of VM locator, because although I'm using bindings, I'm not using "full" MVVM - I'm using a Redux-like architecture instead. And I guess a VM locator wouldn't work for this case anyway for the same reasons the above doesn't work.)

Viewing all 77050 articles
Browse latest View live


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