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

How to ACCESS DATABASE in XAMARIN.FORMS?

$
0
0

Good Day everyone. I'm having trouble on how am I going to show all the records I have created in my ASP.NET WEB API to Xamarin.Forms Application. I tried creating pre-defined list of Employee's Name and Department and it worked. But what I want to do is Create a Record in ASP.NET Web Application and make it appear to my mobile application. Any help will be highly appreciated. Here's my code. I'm just a newbie so please forgive me if my question isn't seem to be informative. Thanks in advance. I watch a video tutorial regarding this matter._ Refer to this link if needed. _ image

MainViemMain.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="XamarinFormsDemo.MainPageMain"
                              xmlns:ViewModels="clr-namespace:XamarinFormsDemo.ViewModels;assembly=XamarinFormsDemo">


                   <ContentPage.BindingContext>
                     <ViewModels:MainViewModel/>
                   </ContentPage.BindingContext>

      <StackLayout>
      <ListView ItemsSource="{Binding EmployeesList}"
                HasUnevenRows="True">
        <ListView.ItemTemplate>
          <DataTemplate>
            <ViewCell>
              <StackLayout Orientation="Vertical"
                           Padding="12,6">
                <Label Text="{Binding Name}"
                       FontSize="24"/>

                <Label Text="{Binding Department}"
                       FontSize="18"
                       Opacity="0.6"/>
              </StackLayout>
            </ViewCell>
          </DataTemplate>
        </ListView.ItemTemplate>

      </ListView>

      <Label Text="Read This!"/>

      </StackLayout>

    </ContentPage>`

MainViewModel.cs

    `using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Linq;
    using System.Runtime.CompilerServices;
    using System.Text;
    using System.Threading.Tasks;
    using XamarinFormsDemo.Models;
    using XamarinFormsDemo.Services;

    namespace XamarinFormsDemo.ViewModels
    {
        public class MainViewModel : INotifyPropertyChanged
        {

            private List<Employee> _employeesList;

            public List<Employee> EmployeesList
            {
                get { return _employeesList; }
                set
                {
                    _employeesList = value;
                    OnPropertyChanged();
                }
            }

            public MainViewModel()
            {
                InitializeDataAsync();
            }

            private async Task InitializeDataAsync()
            {
                var employeesServices = new EmployeesServices();

                EmployeesList = await employeesServices.GetEmployeesAsync();
            }



            public event PropertyChangedEventHandler PropertyChanged;

            protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
            {
                var handler = PropertyChanged;
                if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
            }


        }
    }`

EmployeesServices.cs

            `
            using Plugin.RestClient;
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using System.Threading.Tasks;
            using XamarinFormsDemo.Models;

            namespace XamarinFormsDemo.Services
            {
                public class EmployeesServices
                {


                    public async Task<List<Employee>> GetEmployeesAsync()
                    {
                        RestClient<Employee> restClient = new RestClient<Employee>();

                        var employeesList = await restClient.GetAsync();

                        return employeesList;

                    }


                }
            }
            `

How can I add a NavigationPage in Xamarin.Forms?

$
0
0

How can I add a NavigationPage in Xamarin.Forms?

so that I want to navigate this page from a link that are on another page
in Xamarin.Forms.

'Resource.Styleable' does not contain a definition

$
0
0

I am getting error when i Installed Xlab 2.0.5782 in Xamarin.android.I got many error like this.
Please give solution for this. i got this type of error many times.when i uninstall Xlabs then all error Solved but i can not integrate with my project.

  `  2>,164): error CS0117: 'Resource.Styleable' does not contain a definition for 'Theme_textColorAlertDialogListItem'
    2>E:\Pranav\xamarin\XamainKcsControl\XamainKcsControl\XamainKcsControl.Droid\Resources\Resource.Designer.cs(1552,120,1552
    2>,144): error CS0117: 'Resource.Styleable' does not contain a definition for 'Theme_textColorSearchUrl'
    2>E:\Pranav\xamarin\XamainKcsControl\XamainKcsControl\XamainKcsControl.Droid\Resources\Resource.Designer.cs(1553,130,1553
    2>,164): error CS0117: 'Resource.Styleable' does not contain a definition for 'Theme_toolbarNavigationButtonStyle'
    2>E:\Pranav\xamarin\XamainKcsControl\XamainKcsControl\XamainKcsControl.Droid\Resources\Resource.Designer.cs(1554,114,1554
    2>,132): error CS0117: 'Resource.Styleable' does not contain a definition for 'Theme_toolbarStyle'
    2>E:\Pranav\xamarin\XamainKcsControl\XamainKcsControl\XamainKcsControl.Droid\Resources\Resource.Designer.cs(1555,117,1555
    2>,138): error CS0117: 'Resource.Styleable' does not contain a definition for 'Theme_windowActionBar'
    2>E:\Pranav\xamarin\XamainKcsControl\XamainKcsControl\XamainKcsControl.Droid\Resources\Resource.Designer.cs(1556,124,1556
    2>,152): error CS0117: 'Resource.Styleable' does not contain a definition for 'Theme_windowActionBarOverlay'
    2>E:\Pranav\xamarin\XamainKcsControl\XamainKcsControl\XamainKcsControl.Droid\Resources\Resource.Designer.cs(1557,125,1557
    2>,154): error CS0117: 'Resource.Styleable' does not contain a definition for 'Theme_windowActionModeOverlay'
    2>E:\Pranav\xamarin\XamainKcsControl\XamainKcsControl\XamainKcsControl.Droid\Resources\Resource.Designer.cs(1558,124,1558
    2>,152): error CS0117: 'Resource.Styleable' does not contain a definition for 'Theme_windowFixedHeightMajor'
    2>E:\Pranav\xamarin\XamainKcsControl\XamainKcsControl\XamainKcsControl.Droid\Resources\Resource.Designer.cs(1559,124,1559
    2>,152): error CS0117: 'Resource.Styleable' does not contain a definition for 'Theme_windowFixedHeightMinor'
    2>E:\Pranav\xamarin\XamainKcsControl\XamainKcsControl\XamainKcsControl.Droid\Resources\Resource.Designer.cs(1560,123,1560
    2>,150): error CS0117: 'Resource.Styleable' does not contain a definition for 'Theme_windowFixedWidthMajor'
    2>E:\Pranav\xamarin\XamainKcsControl\XamainKcsControl\XamainKcsControl.Droid\Resources\Resource.Designer.cs(1561,123,1561
    2>,150): error CS0117: 'Resource.Styleable' does not contain a definition for 'Theme_windowFixedWidthMinor'
    2>E:\Pranav\xamarin\XamainKcsControl\XamainKcsControl\XamainKcsControl.Droid\Resources\Resource.Designer.cs(1562,121,1562
    2>,146): error CS0117: 'Resource.Styleable' does not contain a definition for 'Theme_windowMinWidthMajor'
    2>E:\Pranav\xamarin\XamainKcsControl\XamainKcsControl\XamainKcsControl.Droid\Resources\Resource.Designer.cs(1563,121,1563
    2>,146): error CS0117: 'Resource.Styleable' does not contain a definition for 'Theme_windowMinWidthMinor'
    2>E:\Pranav\xamarin\XamainKcsControl\XamainKcsControl\XamainKcsControl.Droid\Resources\Resource.Designer.cs(1564,115,1564
    2>,134): error CS0117: 'Resource.Styleable' does not contain a definition for 'Theme_windowNoTitle' `

How to get the IMEI number

$
0
0

Hello,

Is there a way to get the IMEI number from Xamarin Forms app?
for android and iOS.

Crash When Going Back to a View on iPhone 4

$
0
0

I'm completly lost on this issue. I have a crash that seems to be only happening on the iPhone 4. This is a line of business app and not supporting the iPhone 4 isn't an option. I have a View with a list that allows users to inspect parts of a room. If they open the detail from the list, then go back the app crashes. I haven't been able to make any sense of the stack trace. I can reproduce this bug with Xamarin Forms 1.5, 2.0 and the latest pre release. Any help would be greatly appreciated.

John Harris

Here is the stack trace.

2016-01-14 11:19:47.131 JlgSiteManagementiOS[468:60b] critical: Stacktrace:

2016-01-14 11:19:47.141 JlgSiteManagementiOS[468:60b] critical:   at <unknown> <0xffffffff>
2016-01-14 11:19:47.145 JlgSiteManagementiOS[468:60b] critical:   at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0xffffffff>
2016-01-14 11:19:47.154 JlgSiteManagementiOS[468:60b] critical:   at UIKit.UIApplication.Main (string[],intptr,intptr) [0x00005] in /Users/builder/data/lanes/2377/73229919/source/maccore/src/UIKit/UIApplication.cs:77
2016-01-14 11:19:47.158 JlgSiteManagementiOS[468:60b] critical:   at UIKit.UIApplication.Main (string[],string,string) [0x0001c] in /Users/builder/data/lanes/2377/73229919/source/maccore/src/UIKit/UIApplication.cs:60
2016-01-14 11:19:47.162 JlgSiteManagementiOS[468:60b] critical:   at JlgSiteManagement.iOS.Application.Main (string[]) [0x00013] in /Users/john/Desktop/branch/JL Gray Site Management/JlgSiteManagement/JlgSiteManagement/JlgSiteManagement.iOS/Main.cs:20
2016-01-14 11:19:47.170 JlgSiteManagementiOS[468:60b] critical:   at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>
2016-01-14 11:19:47.173 JlgSiteManagementiOS[468:60b] critical: 
Native stacktrace:

2016-01-14 11:19:48.407 JlgSiteManagementiOS[468:60b] critical:     0   JlgSiteManagementiOS                0x0171d509 mono_handle_native_sigsegv + 240
2016-01-14 11:19:48.412 JlgSiteManagementiOS[468:60b] critical:     1   JlgSiteManagementiOS                0x017242fb mono_sigsegv_signal_handler + 226
2016-01-14 11:19:48.416 JlgSiteManagementiOS[468:60b] critical:     2   libsystem_platform.dylib            0x3b15bf93 _sigtramp + 42
2016-01-14 11:19:48.419 JlgSiteManagementiOS[468:60b] critical:     3   UIKit                               0x32c6fed7 <redacted> + 2042
2016-01-14 11:19:48.423 JlgSiteManagementiOS[468:60b] critical:     4   UIKit                               0x32c72dc5 <redacted> + 56
2016-01-14 11:19:48.426 JlgSiteManagementiOS[468:60b] critical:     5   UIKit                               0x32d24611 <redacted> + 1432
2016-01-14 11:19:48.431 JlgSiteManagementiOS[468:60b] critical:     6   UIKit                               0x32d166c5 <redacted> + 476
2016-01-14 11:19:48.434 JlgSiteManagementiOS[468:60b] critical:     7   UIKit                               0x32d902df <redacted> + 322
2016-01-14 11:19:48.437 JlgSiteManagementiOS[468:60b] critical:     8   JlgSiteManagementiOS                0x017e58f0 _ZL33invoke_objc_method_implementationP11objc_objectP13objc_selectorPFS0_S0_S2_zE + 68
2016-01-14 11:19:48.439 JlgSiteManagementiOS[468:60b] critical:     9   JlgSiteManagementiOS                0x017e5890 xamarin_release_trampoline + 236
2016-01-14 11:19:48.442 JlgSiteManagementiOS[468:60b] critical:     10  JlgSiteManagementiOS                0x016e3813 -[Xamarin_Forms_Platform_iOS_FormsUITableViewController release] + 18
2016-01-14 11:19:48.445 JlgSiteManagementiOS[468:60b] critical:     11  CoreFoundation                      0x302b48ed CFRelease + 556
2016-01-14 11:19:48.448 JlgSiteManagementiOS[468:60b] critical:     12  UIKit                               0x32c206dd <redacted> + 324
2016-01-14 11:19:48.450 JlgSiteManagementiOS[468:60b] critical:     13  UIKit                               0x32b99557 <redacted> + 458
2016-01-14 11:19:48.453 JlgSiteManagementiOS[468:60b] critical:     14  CoreFoundation                      0x3034f255 <redacted> + 20
2016-01-14 11:19:48.458 JlgSiteManagementiOS[468:60b] critical:     15  CoreFoundation                      0x3034cbf9 <redacted> + 284
2016-01-14 11:19:48.463 JlgSiteManagementiOS[468:60b] critical:     16  CoreFoundation                      0x3034cf3b <redacted> + 730
2016-01-14 11:19:48.467 JlgSiteManagementiOS[468:60b] critical:     17  CoreFoundation                      0x302b7ebf CFRunLoopRunSpecific + 522
2016-01-14 11:19:48.470 JlgSiteManagementiOS[468:60b] critical:     18  CoreFoundation                      0x302b7ca3 CFRunLoopRunInMode + 106
2016-01-14 11:19:48.472 JlgSiteManagementiOS[468:60b] critical:     19  GraphicsServices                    0x351bd663 GSEventRunModal + 138
2016-01-14 11:19:48.474 JlgSiteManagementiOS[468:60b] critical:     20  UIKit                               0x32c0414d UIApplicationMain + 1136
2016-01-14 11:19:48.478 JlgSiteManagementiOS[468:60b] critical:     21  JlgSiteManagementiOS                0x00f2bf20 wrapper_managed_to_native_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 272
2016-01-14 11:19:48.485 JlgSiteManagementiOS[468:60b] critical:     22  JlgSiteManagementiOS                0x00e8ed0c UIKit_UIApplication_Main_string___intptr_intptr + 52
2016-01-14 11:19:48.488 JlgSiteManagementiOS[468:60b] critical:     23  JlgSiteManagementiOS                0x00e8eccc UIKit_UIApplication_Main_string___string_string + 204
2016-01-14 11:19:48.490 JlgSiteManagementiOS[468:60b] critical:     24  JlgSiteManagementiOS                0x00095c1c JlgSiteManagement_iOS_Application_Main_string__ + 268
2016-01-14 11:19:48.493 JlgSiteManagementiOS[468:60b] critical:     25  JlgSiteManagementiOS                0x008932f0 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 256
2016-01-14 11:19:48.496 JlgSiteManagementiOS[468:60b] critical:     26  JlgSiteManagementiOS                0x01726947 mono_jit_runtime_invoke + 1150
2016-01-14 11:19:48.498 JlgSiteManagementiOS[468:60b] critical:     27  JlgSiteManagementiOS                0x01776945 mono_runtime_invoke + 88
2016-01-14 11:19:48.501 JlgSiteManagementiOS[468:60b] critical:     28  JlgSiteManagementiOS                0x0177a00b mono_runtime_exec_main + 282
2016-01-14 11:19:48.506 JlgSiteManagementiOS[468:60b] critical:     29  JlgSiteManagementiOS                0x017fba1c xamarin_main + 2072
2016-01-14 11:19:48.508 JlgSiteManagementiOS[468:60b] critical:     30  JlgSiteManagementiOS                0x016f46b1 main + 112
2016-01-14 11:19:48.511 JlgSiteManagementiOS[468:60b] critical:     31  libdyld.dylib                       0x3b041ab7 <redacted> + 2
2016-01-14 11:19:48.513 JlgSiteManagementiOS[468:60b] critical: 
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Is there any way to show Tabs on bottom in Android using TabbedPageRenderer?

$
0
0

I wanted to customize tabs on Android as they are shown in iOS instead of native look on android. Can this be achieved using TabbedPageRendere?

Forms9Patch: Simplify multi-device image management in your PCL Xamarin.Forms mobile apps

$
0
0

Announcement of Form9Patch

Xamarin Forms is great for developing apps on Android and iOS but it is missing two important tools for developers: scalable images and PCL multi-screen image management. Android developers use NinePatch bitmaps and the drawable directory naming convention for this purpose. Likewise, iOS developers use ResizeableImageWithCapInsets and the @2x, @3x, @4x file naming convention for this purpose.

Forms 9 Patch enhances Xamarin Forms to enable multi-resolution / multi-screen image management to PCL apps for iOS and Android.

What is it?

Simply stated, Forms9Patch is two separate elements (Image and ImageSource) which are multi-screen / multi-resolution extensions of their Xamarin Forms counterparts.

Forms9Patch.ImageSource

Xamarin Forms provides native iOS and Android multi-screen image management (described here). This requires storing your iOS images using the native iOS schema and storing your Android images using the Android schema. In other words, duplicative efforts to get the same results on both Android and iOS. Forms9Patch.ImageSource extends Xamarin.Forms.ImageSource capabilities to bring multi-screen image management to your PCL assemblies - so you only have to generate and configure your app's image resources once. Forms9Patch.ImageSource is a cross-platform implementation to sourcing multi-screen images in Xamarin Forms PCL apps as embedded resources.

Forms9Patch.Image

Forms9Patch.Image compliments Xamarin.Forms.Image to provide Xamarin Forms with a scaleable image element. Scalable images are images that fill their parent view by stretching in designated regions. The source image for the Forms9Patch.Image element can be specified either as a Forms9Patch.ImageSource or a Xamarin.Forms.ImageSource. Supported file formats are NinePatch (.9.png), .png, .jpg, .jpeg, .gif, .bmp, and .bmpf.

Example code

After adding the file bubble.9.png to your PCL project assembly as an EmbeddedResource, you can display it using something like the following:

var bubbleImage = new Forms9Patch.Image () {
    Source = ImageSource.FromResource("MyDemoApp.Resources.bubble.9.png"),
    HeightRequest = 110,
}
var label = new label () {
    Text = "Forms9Path NinePatch Image",
    HorizontalOptions = LayoutOptions.Center,
}

Example XAML

In Xamarin Forms, access to embedded resources from XAML requires some additional work. Unfortunately, Forms9Patch is no different. As with Xamarin Forms, you will need (in the same assembly as your embedded resource images) a simple custom XAML markup extension to load images using their ResourceID.

    [ContentProperty ("Source")]
    public class ImageMultiResourceExtension : IMarkupExtension
    {
        public string Source { get; set; }

        public object ProvideValue (IServiceProvider serviceProvider)
        {
            if (Source == null)
                return null;

            // Do your translation lookup here, using whatever method you require
            var imageSource = Forms9Patch.ImageSource.FromMultiResource(Source);

            return imageSource;
        }
    }

Once you have the above, you can load your embedded resource images as shown in the below example. Be sure to add a namespace for the assembly that contains both your MarkupExtension and your EmbeddedResources (local in the below example).

<?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:local="clr-namespace:MyXamlDemo;assembly=MyXamlDemo"
    x:Class="MyXamlDemo.MyPage"
    Padding="5, 20, 5, 5">
    <ScrollView>
        <ScrollView.Content>
            <StackLayout>
            <Label Text="Xamarin.Image"/>
            <Image Source="{local:ImageMultiResource Forms9PatchDemo.Resources.image}"/>
            </StackLayout>
        </ScrollView.Content>
    </ScrollView>
</ContentPage>

Where to learn more

Project page: http://Forms9Patch.com
Nuget page: https://www.nuget.org/packages/Forms9Patch/0.9.1
Demo app repository: https://github.com/baskren/Forms9PatchDemo

Created a perfect Exapandable ListView (iOS) row by NOT using ForceUpdateSize, what gives?

$
0
0

So I've been struggling with creating an expandable ListView row. It seems people have been having a lot of trouble with this in the past. Recently a new ViewCell method called "ForceUpdateSize" was added. This allowed me to create a custom ViewCell which called "ForceUpdateSize" and changed the Height on itself when a certain event was fired on the BindingContext object. This did work and the item would fold in and out but it was lagging and strange bugs would occur (iOS) where you could see other items flickering, moving up/down and so on. Also I could not change the default animations.

For those interested however I just solved this on iOS by using a CustomRenderer to get hold of the UITableView. I then stored that reference and could via another class call the method "_uiTableView.ReloadRows(...)" instead of ForceUpdateSize(). Now it works perfectly and the animation looks great + no lagging! I can also pick from all the available iOS animations.

So my question is, what is the reason for this? Is the Xamarin.Forms implementation not as simple as calling ReloadRows? Does it invalidate the full layout etc?

Anyway if you want a perfect result for now you should do similair to how I did it.


Compiling Error: Xamarin.iOS.Common.targets

$
0
0

Xamarin Studio 6.0(build 5174)

From Errors:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets: Error: Error executing task ReadItemsFromFile: Name cannot begin with the '<' character, hexadecimal value 0x3C. Line 3, position 2.

From LogFile:

Target _ReadCoreCompileInterfaceDefinitions:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets: error : Error executing task ReadItemsFromFile: Name cannot begin with the '<' character, hexadecimal value 0x3C. Line 3, position 2.
Build FAILED.
Errors:

    /Users/simplesolutionsMAC/Documents/Projectos/JunaNote/iOS/JunaNote.iOS.csproj (Build) ->

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets (_ReadCoreCompileInterfaceDefinitions target) ->

        /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets: error : Error executing task ReadItemsFromFile: Name cannot begin with the '<' character, hexadecimal value 0x3C. Line 3, position 2.

         0 Warning(s)
         1 Error(s)

    Time Elapsed 00:00:00.2195200

How can I connect to an existing MS-SQL database ?

$
0
0

How can I connect to an existing MS-SQL database ?

I need to create a local database table for my cross-platform app with sqlLite in vs2015

$
0
0

I'm a Beginner to Xamarin.form cross platform app creation using VS 2015. so, please give me some suggestions for creating a local database and easy access of the database data within the application in a quick way without much complexity.

Thanks :)

Xamarin.Forms Bindable Picker

$
0
0

If anyone wonders how to make a Bindable Picker, here's the code:

`

public class BindablePicker : Picker
{
    #region Fields

    //Bindable property for the items source
    public static readonly BindableProperty ItemsSourceProperty =
        BindableProperty.Create<BindablePicker, IEnumerable>(p => p.ItemsSource, null, propertyChanged: OnItemsSourcePropertyChanged);

    //Bindable property for the selected item
    public static readonly BindableProperty SelectedItemProperty =
        BindableProperty.Create<BindablePicker, object>(p => p.SelectedItem, null, BindingMode.TwoWay, propertyChanged: OnSelectedItemPropertyChanged);

    #endregion

    #region Properties

    /// <summary>
    /// Gets or sets the items source.
    /// </summary>
    /// <value>
    /// The items source.
    /// </value>
    public IEnumerable ItemsSource
    {
        get { return (IEnumerable)GetValue(ItemsSourceProperty); }
        set { SetValue(ItemsSourceProperty, value); }
    }

    /// <summary>
    /// Gets or sets the selected item.
    /// </summary>
    /// <value>
    /// The selected item.
    /// </value>
    public object SelectedItem
    {
        get { return GetValue(SelectedItemProperty); }
        set { SetValue(SelectedItemProperty, value); }
    }

    #endregion

    #region Methods

    /// <summary>
    /// Called when [items source property changed].
    /// </summary>
    /// <param name="bindable">The bindable.</param>
    /// <param name="value">The value.</param>
    /// <param name="newValue">The new value.</param>
    private static void OnItemsSourcePropertyChanged(BindableObject bindable, IEnumerable value, IEnumerable newValue)
    {
        var picker = (BindablePicker)bindable;
        var notifyCollection = newValue as INotifyCollectionChanged;
        if (notifyCollection != null)
        {
            notifyCollection.CollectionChanged += (sender, args) =>
            {
                if (args.NewItems != null)
                {
                    foreach (var newItem in args.NewItems)
                    {
                        picker.Items.Add((newItem ?? "").ToString());
                    }
                }
                if (args.OldItems != null)
                {
                    foreach (var oldItem in args.OldItems)
                    {
                        picker.Items.Remove((oldItem ?? "").ToString());
                    }
                }
            };
        }

        if (newValue == null) 
            return;

        picker.Items.Clear();

        foreach (var item in newValue)
            picker.Items.Add((item ?? "").ToString());
    }

    /// <summary>
    /// Called when [selected item property changed].
    /// </summary>
    /// <param name="bindable">The bindable.</param>
    /// <param name="value">The value.</param>
    /// <param name="newValue">The new value.</param>
    private static void OnSelectedItemPropertyChanged(BindableObject bindable, object value, object newValue)
    {
        var picker = (BindablePicker)bindable;
        if (picker.ItemsSource != null)
            picker.SelectedIndex = picker.ItemsSource.IndexOf(picker.SelectedItem);
    }

    #endregion
}

`

Usage is pretty straight forward..:

<local:BindablePicker ItemsSource="{Binding Cats}" SelectedItem="{Binding SelectedCat}"/>

It would've been nice that the Xamarin.Forms.Picker already had this functionality, maybe we'll see it in a next update...

Any questions, comments, or contributions are welcome :)

How to add two full-sized view(equal size with screen) into scrollview on Xamarin.forms?

$
0
0

Hi,

I'm making app using with Xamarin.forms.
What I'm doing is really hard. Can't figure out so far.

I want to add two view into scrollview and size of each view is equal with screen size. So If I scroll down, second view show up and first view will be hidden.

How to make it with using xaml?

I tried stacklayout, grid, relative, absolute.
Nothing works. (I believe there is some way to do it)

Thanks.

Xamarin Forms app with PCL on XS: out of memory error at build time...

$
0
0

Hi all,
I updated Xamarin Studio and the libraries to the last version on the beta channel today.
Now I can't build any Xamarin forms app (either for iOS or Droid), for an out of memory error that won't disappear if I clean, restart XS, reboot the Mac.

My config:
MacBookPro i7 8Gb RAM SSD
Xamarin Studio 6.0.1 (build 9)
Forms 2.0.3.49

This is the error.

/Users/ricc/Projects/AppName/AppName/AppName.Business.csproj (Build) ->
/Library/Frameworks/Mono.framework/Versions/4.4.1/lib/mono/4.5/Microsoft.CSharp.targets (CoreCompile target) ->
/Library/Frameworks/Mono.framework/Versions/4.4.1/lib/mono/4.5/Microsoft.CSharp.targets: error : Error executing tool '/Library/Frameworks/Mono.framework/Versions/4.4.1/lib/mono/4.5/mcs.exe': ApplicationName='/Library/Frameworks/Mono.framework/Versions/4.4.1/lib/mono/4.5/mcs.exe', CommandLine='/noconfig @/var/folders/8b/ksk06c7x77118m3trl29bdwr0000gn/T/tmp5632057.tmp', CurrentDirectory='/Users/riccardom/Projects/AppName/AppName.Business', Native error= Out of memory

Any ideas? thank you...
Tags

HttpWebRequest https problems

$
0
0

Hi guys,

Setup:
Windows 7
Visual Studio 2015
OS X Yosemite
Xamarin (latest stable version)

I've been trying to solve this issue. I cannot seem to get any solid information on it. But OK in short I've been trying to make this app for (iOS and android) that I go to this (https) URL and fetch the information and display the information (synchronously). Very straightforward and very easy.

Before I went and put too much effort and work into it I decided to make a console application on my windows 7 machine. I wrote a class there and EVERYTHING was working with no issues.

So I started to make the app and I got to a point where I was going use my class I wrote earlier. I was expecting things to go smooth but no! I was hoping for a clear error but no! It just tells me that the request has timeout. It times out at the following line:

HttpWebResponse response = (HttpWebResponse)request.GetResponse();

This is what I'm seeing when I get the exception:

{System.Net.WebException: The request timed out
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00046] in /Users/builder/data/lanes/2077/1d27ac2c/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System/System.Net/HttpWebRequest.cs:940
at System.Net.HttpWebRequest.GetResponse () [0x0000e] in /Users/builder/data/lanes/2077/1d27ac2c/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/mcs/class/System/System.Net/HttpWebRequest.cs:958

I did try other URLs just to be sure. It seems to be working fine with HTTP URLs but it has some problems with some HTTPS URLs.

I'm not sure if I'm doing something wrong or the mono/xamarin implementation of HttpWebRequest is not done properly because I was expecting no problems at this point.

I tried asynchronously and I'm still waiting for the callback...

I tried to put a trace on webrequest to see if I could gather more info on what is going wrong but I'm not sure how to do that with xamarin.forms.

Any help or information on the matter is very welcome at this moment.


barcode scanning in a Forms app

$
0
0

I need to integrate barcode scanning into my Xamarin.Forms prototype app.

Before I go down this road, has anyone already done it, or does anyone have a suggestion about how to best approach it?

Bug with BindingContext

$
0
0

Hi !
I'm working on a Xamarin.Forms app, and i have 3 pages and 3 viewModel.
So i use BindingContext of each Pages, i Binded the ViewModel.
As you can see in the attached files, i have an error on the Source part of my TestPage.
Do you know why ?

How to get Navigation back button event in Xamarin forms

$
0
0

In my project on one page there is a form to add products.
if user doesn't save the details and pressed back button, at that time I want to display the action sheet having Discard, Save, Cancel options.
I'm unable to get the back button pressed event.
I'm working in Xamarin studio and used cross platform with xamarin form

I've already tried OnBackButtonPressed event but it doesn't get call

protected override bool OnBackButtonPressed()
{

Device.BeginInvokeOnMainThread(async() => {
    var result = await DisplayActionSheet("Action","Cancel",null,"Discard","Save");
        //if (result) await this.Navigation.PopAsync(); // or anything else
    });

return base.OnBackButtonPressed();

}

Convert Image Path to Base64

Vertical Slider

$
0
0

Hey Guys thanks in advance!
So I need a vertical slider. I only found this option but can't apply it on my Xamarin.forms slider! Please help.
https://forums.xamarin.com/discussion/3007/custom-vertical-uislider-example-anywhere

What I tried:
Step1: Rotation - Does not work because the slider will take the width of the Layoutbox anyway!
Step2: Stacklayout.Orientation - Does strange things.
Step3: CustomSlider - But there are not enough exposed settings achieve what I want!

class CustomSlider : Slider
    {
        public CustomSlider()
        {
            this.BackgroundColor = Color.Red;
            //this.Rotation = -90;
            //this.AnchorX = 0.5;
            //this.AnchorY = 0.5;

            System.Diagnostics.Debug.WriteLine(" ");
            System.Diagnostics.Debug.WriteLine(" ");
            System.Diagnostics.Debug.WriteLine(" ");
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: ID " + this.Id);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: Bounds " + this.Bounds.ToString());
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: AnchorX " + this.AnchorX.ToString());
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: AnchorY " + this.AnchorY.ToString());
            System.Diagnostics.Debug.WriteLine(">> ");
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: RequestH " + this.HeightRequest);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: RequestW " + this.WidthRequest);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: Height " + this.Height);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: Width " + this.Width);
            System.Diagnostics.Debug.WriteLine(">> ");
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: VOptionsA " + this.VerticalOptions.Alignment);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: HOptionsA " + this.HorizontalOptions.Alignment);
            System.Diagnostics.Debug.WriteLine(">> ");
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: VOptionsE " + this.VerticalOptions.Expands);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: HOptionsE " + this.HorizontalOptions.Expands);
            System.Diagnostics.Debug.WriteLine(">> ");
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: Scale " + this.Scale);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: RotX " + this.RotationX);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: RotY " + this.RotationY);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: RotZ " + this.Rotation);
            System.Diagnostics.Debug.WriteLine(">> ");
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: TransX " + this.TranslationX);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: TransY " + this.TranslationY);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: XPos " + this.X);
            System.Diagnostics.Debug.WriteLine(">> CUSTOM SLIDER: YPos " + this.Y);
            System.Diagnostics.Debug.WriteLine(" ");
            System.Diagnostics.Debug.WriteLine(" ");
            System.Diagnostics.Debug.WriteLine(" ");
        }
    }

How can I make myself a slider that can be vertical from bottom to top, filling my Layout-Grid-Cell?
Or has someone an example? The XLabs ExtendedSlider does not have a vertical setting as well if I am correct.

Viewing all 81910 articles
Browse latest View live


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