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

TimePicker doesn't respect local setting (24hr formatting)

$
0
0

Hi there

My phone (Android) has its locale set to en-us, but time on my phone is displayed in 24 hour format (as configured on the phone). This is respected by every single app on my phone.

However, I noticed today that when displaying a TimePicker on my Xamarin Forms app, Xamarin displays a 12 hr time picker (probably according to the system locale).

That's the first problem. Next is to actually render the time on the UI. Here again, Xamarin fails with a ToString("t") - not surprisingly since this is just based on the UI CultureInfo. So I would need a device-specific time formatting method or the device configuration.

Showing a picker and displaying something as typical as time on a UI is a feature I would expect to just work out of the box. Is there anything in Xamarin Forms I overlooked? And if not, is this a known issue (that hopefully will be fixed soon)?

Thanks,
Philipp


CachedImage FFImageLoading for Xamarin.Forms

$
0
0

https://github.com/molinch/FFImageLoading or https://github.com/daniel-luberda/FFImageLoading/ (new Forms features)

DEMO: https://github.com/daniel-luberda/FFImageLoading/tree/master/samples/ImageLoading.Forms.Sample

Caching support

The library automatically deduplicates similar requests: if 100 similar requests arrive at same time then one real loading will be performed while 99 others will wait. When the 1st real read is done then the 99 waiters will get the image.

Both a memory cache and a disk cache are present.

By default, on Android, images are loaded without transparency channel. This allows saving 50% of memory since 1 pixel uses 2 bytes instead of 4 bytes in RGBA (it can be changed).

WebP support

WebP is supported on both iOS and Android.

Downsampling

Downloaded images can be automatically downsampled to specified size (less memory usage). DownsampleHeight and DownsampleWidth properties

Retry

Downloads can be repeated if not succeeded: RetryCount and RetryDelay properties.

Placeholders support

  • LoadingPlaceholder

  • ErrorPlaceholder

image image

After this pull it'll also support Transformations!
https://github.com/molinch/FFImageLoading/pull/47

Transformations support

It doesn't modify original source images. Example:

  • RoundedTransformation

  • CircleTransformation

  • GrayscaleTransformation

image image

... and some more features. Feel free to test it. Not all features are on nuget yet (older version).

ListView long press PCL

$
0
0

Hello everyone.

I need to use or add the LongPress method in my app.

Does anyone have a good example to develop this event?

ExtendedBoxRenderer with Radius and Shadow

$
0
0

I was trying to find help online for ExtendedBoxRenderer on Android that would allow me to add border radius and shadow. While I couldn't get much help, I did come up with my own solution. So I am posting it here just in case anyone wants to achieve the same thing.

Control
`
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace Mobile.Controls.Home
{
    public class ExtendedBoxView : BoxView
    {
        /// <summary>
        /// Respresents the background color of the button.
        /// </summary>
        public static readonly BindableProperty BorderRadiusProperty = BindableProperty.Create<ExtendedBoxView, double>(p => p.BorderRadius, 0);

        public double BorderRadius
        {
            get { return (double)GetValue(BorderRadiusProperty); }
            set { SetValue(BorderRadiusProperty, value); }
        }

        public static readonly BindableProperty StrokeProperty =
            BindableProperty.Create<ExtendedBoxView, Color>(p => p.Stroke, Color.Transparent);

        public Color Stroke
        {
            get { return (Color)GetValue(StrokeProperty); }
            set { SetValue(StrokeProperty, value); }
        }

        public static readonly BindableProperty StrokeThicknessProperty =
            BindableProperty.Create<ExtendedBoxView, double>(p => p.StrokeThickness, 0);

        public double StrokeThickness
        {
            get { return (double)GetValue(StrokeThicknessProperty); }
            set { SetValue(StrokeThicknessProperty, value); }
        }


    }
}

`
Android Renderer

`

using Android.Graphics;
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(ExtendedBoxView), typeof(ExtendedBoxViewRenderer))]
namespace Mobile.Droid
{
    /// <summary>
    ///
    /// </summary>
    public class ExtendedBoxViewRenderer : VisualElementRenderer<BoxView>
    {
        /// <summary>
        ///
        /// </summary>
        public ExtendedBoxViewRenderer()
        {
        }
        /// <summary>
        ///
        /// </summary>
        protected override void OnElementChanged(ElementChangedEventArgs<BoxView> e)
        {
            base.OnElementChanged(e);

            SetWillNotDraw(false);

            Invalidate();
        }

    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
    {
        base.OnElementPropertyChanged(sender, e);

        if (e.PropertyName == ExtendedBoxView.BorderRadiusProperty.PropertyName)
        {
            Invalidate();
        }
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="canvas"></param>
    public override void Draw(Canvas canvas)
    {
        var box = Element as ExtendedBoxView;
        base.Draw(canvas);
        Paint myPaint = new Paint();

        myPaint.SetARGB(convertTo255ScaleColor(box.Color.A), convertTo255ScaleColor(box.Color.R), convertTo255ScaleColor(box.Color.G), convertTo255ScaleColor(box.Color.B));
        myPaint.SetShadowLayer(20, 0, 5, Android.Graphics.Color.Argb(100, 0, 0, 0));

        SetLayerType(Android.Views.LayerType.Software, myPaint);

        RectF rectF = new RectF(
                    10, // left
                    10, // top
                    canvas.Width - 10, // right
                    canvas.Height - 10 // bottom
            );


        canvas.DrawRoundRect(rectF, 5, 5, myPaint);
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="color"></param>
    /// <returns></returns>
    private int convertTo255ScaleColor(double color)
    {
        return (int) Math.Ceiling(color * 255);
    }
}

}
`

iOS Renderer

`

    using CoreGraphics;
    using Pounce.Mobile.Controls.Home;
    using Pounce.Mobile.iOS.Renderers.Home;
    using System;
    using System.Collections.Generic;
    using System.Text;
    using UIKit;
    using Xamarin.Forms;
    using Xamarin.Forms.Platform.iOS;

    [assembly: ExportRenderer(typeof(ExtendedBoxView), typeof(ExtendedBoxViewRenderer))]
    namespace Pounce.Mobile.iOS.Renderers.Home
    {
        public class ExtendedBoxViewRenderer : VisualElementRenderer<BoxView>
    {
        public ExtendedBoxViewRenderer()
        {
        }

        protected override void OnElementChanged(ElementChangedEventArgs<BoxView> e)
        {
            base.OnElementChanged(e);
            if (Element == null)
                return;

            Layer.MasksToBounds = true;
            Layer.CornerRadius = (float)((ExtendedBoxView)this.Element).BorderRadius / 2.0f;
        }

        public override void Draw(CGRect rect)
        {
            ExtendedBoxView rbv = (ExtendedBoxView)this.Element;
            using (var context = UIGraphics.GetCurrentContext())
            {
                context.SetFillColor(rbv.Color.ToCGColor());
                context.SetStrokeColor(rbv.Stroke.ToCGColor());
                context.SetLineWidth((float)rbv.StrokeThickness);

                var rc = this.Bounds.Inset((int)rbv.StrokeThickness, (int)rbv.StrokeThickness);

                nfloat radius = (nfloat)rbv.BorderRadius;
                radius = (nfloat)Math.Max(0, Math.Min(radius, Math.Max(rc.Height / 2, rc.Width / 2)));

                var path = CGPath.FromRoundedRect(rc, radius, radius);
                context.AddPath(path);
                context.DrawPath(CGPathDrawingMode.FillStroke);
            }
        }

    }
}

`

XAML

<Controls:ExtendedBoxView
                                x:Name="search_boxview"
                                Color="#B32A84D3"
                                BorderRadius="5"/>

error when compile

$
0
0

Hi,
I create a new project. I use visual studio 2013 with xamarin. When i run project this appears. In atach.

Login Button requires two taps with soft keyboard on iOS

$
0
0

I have noticed with my login page on iOS that the user needs to tap twice on the login button to sign in.
The first tap on the sign in button only dismisses the soft keyboard, no click event by the button is received.
The second tap on the sign in button then works.
On Android the login button works as expected when tapped with the soft keyboard showing.

I have wired up a simple test app in xcode with a textfield and button and I can get the button to push the next viewcontroller when the soft keyboard is shown.

Is there something I should be doing in Xamarin forms for iOS to allow the tap gesture to pass thru to the button?

ERROR XAMARIN

$
0
0

Hi, this error appears when i run project. In atach. I use visual studio 2015

Load xaml layout at runtime

$
0
0

Hi,

i was wondering if it is possible to load a form from a xaml file during runtime? So the form is created dynamically.

Regards,

Per


Improving workflow by dynamically loading XAML

$
0
0

Ok, so I know Xamarin doesn't have the ability to load XAML dynamically even though it is (was?) THE MOST requested feature (see this post from May http://forums.xamarin.com/discussion/17258/load-xaml-layout-at-runtime). Anyway, my typical workflow goes like this:

  1. Make some modifications in XAML or C#.
  2. Press F5.
  3. Twiddle my thumbs for a minute or two while it builds and deploy.
  4. Check my changes

    • If my change is OK (20% of the time) great!
    • If my changes are not OK (80% of the time) go to (1)

Now, I really don't like step number 3, it's a HUGE time waster because building, packaging and deploying is a lengthy process but even more because I totally lose my focus (aka flow. aka state of being in the zone) which I have to regain later. I'm starting to compare it to the time gained by not having to develop two separate apps. It's really frustrating.

So what I want to do is load XAML dynamically so I don't have to wait for a full build cycle to see by changes. I really can't see anything preventing a third party implement this so I'm planning to do it myself. Has anyone attempted this before? Are you guys going to add this in the near future? If you are please tell me, or give me a hint or something (if it's a secret for Evolve) since I don't want to invest my time implementing a feature that you guys are also implementing.

The way I'm planning to do it is by getting the XAML from the network, parsing it with an XML parser and then using reflection to build the layout in a big try-catch block. There are some edge cases (like new Images) but there are work arounds.

I'll be creating a GitHub project so if anyone is interested in helping you will be very much welcomed. I can foresee creating several different decoupled components, e.g: a server hosting the xaml file, and the Page subclass that builds the layout on the app side (these two can be developed in parallel).

What do you guys think?

Programmatically switch between Tabs in a TabbedPage

$
0
0

Title says it all :) Is there a way to programmatically switch between Tabs in a TabbedPage.

UWP application crashing in release mode

$
0
0

I am working on a UWP application using visual studio 2015 and when I try distributing the build in release mode, I am getting a crash after the splash screen and am not sure why is this happening, so I checked in my system for logs and all i could find is given below

Faulting application name: MY_APP_NAME.exe, version: 1.0.0.0, time stamp: 0x56cffb04
Faulting module name: Windows.UI.Xaml.dll, version: 10.0.10240.16548, time stamp: 0x56133a14
Exception code: 0xc000027b
Fault offset: 0x00000000004aee7f
Faulting process id: 0xec0
Faulting application start time: 0x01d1706defdfbb8f
Faulting application path: C:\Program Files\WindowsApps\2b976af7-ee0f-4c78-9159-cc5ee34dbe5e_1.0.8.0_x64__75cr2b68sm664\MY_APP_NAME.exe
Faulting module path: C:\Windows\System32\Windows.UI.Xaml.dll
Report Id: 0ce1407c-fdca-41c4-8d67-64478707d461
Faulting package full name: 2b976af7-ee0f-4c78-9159-cc5ee34dbe5e_1.0.8.0_x64__75cr2b68sm664
Faulting package-relative application ID: App

I came across this link which says that its some sort of an issue with the release mode, but am not very sure if that's the case. Please suggest what needs to be done to resolve this.

Note: The application works fine in Debug mode its just the release mode which causes the issue.

XamlReader

$
0
0

Why I do not see in my code XamlReader?

Object xamlObj = XamlReader.Load(xaml);

I'm using 1.4 and PCL Library.
Thanks.

Load Xaml Dynamically At Runtime

$
0
0

Everybody knows that this is an absolute necessity. Everybody is howling about this, and has been for years. However, it still seems as though it is impossible, through normal means to render Xamarin Forms UI at runtime with dynamic Xaml. I'm not really interested in why this hasn't been done yet. What I want to know is WHEN is it going to be done? And, if there is no answer to that, how do we work around this gaping, chasm of a deficiency?

As I see it, there may be two possible approaches to working around this disgusting, blatant inadequacy:

1) Write a Xaml parser that dynamically builds objects and sets their bindings programmatically. This will be hard work, and I don't have time to be doing this. Has anyone else started an open source project to try to achieve this?

2) Take the internal XamlLoader (https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Xaml/XamlLoader.cs) code, and make a version which is public. Has anyone had any luck doing this?

Note: incidentally, you can see the code for the XamlLoader here: https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Xaml/XamlLoader.cs . There doesn't seem to be an explanation for why this class is not public.

read xml files

$
0
0

Does anyone have an example of a connection to xml files, and show in the listview?

Custom Render Bar

$
0
0

Hello colleagues..

Someone has any idea how to create a bar to the image that I show .. would be much appreciated ...

Any idea, guide, etc .. will be of good help ..

Thanks in advance


Set selected List view background color

$
0
0

Hi ,

I used list view in Xamarin forms application, In this i need to set the background color or transparent color for selected cell is this possible ?

`var cell = new DataTemplate (typeof(ImageCell));

        cell.SetBinding (TextCell.TextProperty, "Name");
        cell.SetBinding (TextCell.DetailProperty, "Location");
        cell.SetBinding (ImageCell.ImageSourceProperty, "Image");

        cell.SetValue (TextCell.TextColorProperty, Color.White);
        cell.SetValue (TextCell.DetailColorProperty, Color.White);


        ListView listView = new ListView {

            ItemsSource = presidents,
            ItemTemplate = cell // Set the ImageCell to the item template for the listview

        };

        listView.BackgroundColor = Color.Transparent;`

Listview selectedItem using MVVM and XAML

$
0
0

I am so frustrated that I cannot find one single WORKING example of how to get the selected item from a listview using XAML and MVVM. I have found numerous incomplete examples using different behaviors. I did find one promising one using Xamarin.Forms.Behaviors but again, couldn't get it to work. I'm new to Xamarin but I have been coding for 15 years and I have to say the learning curve here has be brutal.

I would really appreciate any help!

The Layout Couldnot be loaded

$
0
0

I am using visual studio 2013. I have installed following packages:
1. jdk-8u121-windows-i586.
2. android-studio-bundle-145.3537739-windows.
3. mono-4.6.2.16-gtksharp-2.12.42-win32-0.
4. Xamarin.VisualStudio _3.11.458.
5. Android sdk tools 25.2.5
6. Android platform tools 25.0.3
7. Android sdk build tools 25.0.2
8. Android sdk build tools 25.0.1
9. Android 7.1.1 (API 25)
i) Sdk Platform
ii) AndroidTV Intel x86 Atom System Image
iii) Android Wear ARM EABI v7a System Image
iv) Android Wear Intel x86 Atom System Image
v) Google ApIs Intel x86 Atom_64 System Image
vi) Google APIs Intel x86 System Image
vii) Sources for Android sdk
10. Android 7.0 (API 24)
i) Sdk Platform
ii) Sources for Android sdk
11. Android 6.0(API 23)
i) Sdk Platform
ii) Sources for Android sdk
12. Androide 5.1.1(API 22)
i) Sdk Platform
ii) Sources for Android sdk
13. Androide 5.0.1(API 21)
i) Sdk Platform
ii) Sources for Android sdk
14. Androide 4.4W.2(API 20)
i) Sdk Platform
ii) Sources for Android sdk
15. Androide 4.4.2(API 19)
i) Sdk Platform
ii) Sources for Android sdk
16. Androide 4.3.1(API 18)
i) Sdk Platform
ii) Sources for Android sdk
17. Androide 4.2.2(API 17)
i) Sdk Platform
ii) Sources for Android sdk
18. Androide 4.1.2(API 16)
i) Sdk Platform
ii) Sources for Android sdk

I also installed following extra packeges:
i) Broken Source Packages
ii) Androide Support Repository
iii) Google Play Services
iv) Google Repository
v) Google Market Apk Expansion
vi) Google Market Licencing
vii) Google USB Driver
viii) Ndk Bundle
I have set the sdk, ndk path in visual studio.
Now the design view of Main.axml is not loading. It showing “The Layout could not be loaded. The operation failed due to internal error.....”
please tell me what should I do?

Page it self refreshed in xamarin google maps in three tabbed page

$
0
0

Hi Xamarin Lovers

i am unable to refresh the whole page it self on xamarin forms google maps on three tabbed pages

please resolve this iisue as soon as possible

old pins also not removed form my map. so conflict two same pins. how to resolve this issue
please resolve this

Thanks in Advance

Disable controls on page in xamarin.forms

$
0
0

Hey all,

I'm using XLab's PopupLayout to display popup on screen in my app.

But the only issue i'm facing, is when the popup is open user is still able to select controls from backside and the page redirects from one page to another page.

Is there any solution by which I can disable all listview / button and tap event from a page?

Viewing all 89864 articles
Browse latest View live


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