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

Cannot set SystemUiVisibility in FormsAppCompatActivity

$
0
0

Starting API 23, android allows to change the Status bar icon/text tint to dark when the bar background is a lighter color.

Adding the following code in OnCreate() of MainActivity works in Xamarin 2.3.1.114 but not in 2.3.3.180 and above. I was wondering if someone has used this and can point me in the right direction!

if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
{
Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
//Window.AddFlags(WindowManagerFlags.TranslucentStatus);
Window.DecorView.SystemUiVisibility = (StatusBarVisibility)SystemUiFlags.LightStatusBar | (StatusBarVisibility)SystemUiFlags.LayoutFullscreen | (StatusBarVisibility)SystemUiFlags.LayoutStable;
}

Exactly similar question here.


How to reference other projects

$
0
0

I am trying to use this component: https://components.xamarin.com/view/signature-pad in my forms app but it doesn't support UWP.
Another user here came up with this https://github.com/pthomas99/SignaturePad which is forked from the source of the first component I mentioned, but as there is no nuget for this version I'm not sure how to use it in my project.
I can build the sample project from this repo and it works great on UWP but I can't figure out how to implement it in my project? Can anyone point me in the right direction? I've tried referencing the same .dll's as the sample project which hasn't worked, not sure If I need to actually add all the files from this repo to my project?

Bluetooth printer

$
0
0

It possible to connect ios to mobile phone via bluetooth and print receipt using printer? Any sample to refer?
please help me

thanks in advance

Proper ViewModel Structure

$
0
0

Since I've been hearing that each view should have its own view model, can I just make the code behind of each page its view model?

How to create a TabbedView

$
0
0

Hello everyone,
i want to create a TabbedView but i haven't yet idea to create it. Anyone can give me some idea, PLZ!!!
Thanks so much!!!

Has anyone run into problems with gesture recognizes in custom XAML repeaters?

$
0
0

I'm using FreshMvvm with an application that is almost completely data driven. We have many places where a repeater type view is highly useful (a list of elements without scrolling baked in). I have been using a modified version of a repeater view I found in another forum post here, and included my code for the view below.

It's been working great until today when I discovered that using this somehow broke the ability to add a tap gesture to an image in a list item. The following XAML works just fine outside the repeater, but not inside.

<Image Source="GreenStar.png"
        WidthRequest="40"
        HeightRequest="40"
        IsVisible="{Binding Acknowledged}">
  <Image.GestureRecognizers>
    <TapGestureRecognizer
        Command="{Binding UnacknowledgeEventCommand}"
        CommandParameter="{Binding .}" />
  </Image.GestureRecognizers>
</Image>

Any help on how I can enable gestures within the RepeaterView would be gratefully appreciated

Btw, it's immensely frustrating that we have made it this far into the life of Xamarin Forms without a native RepeaterView

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using Xamarin.Forms;

public delegate void RepeaterViewItemAddedEventHandler(object sender, RepeaterViewItemAddedEventArgs args);

// in lieu of an actual Xamarin Forms ItemsControl, this is a heavily modified version of code from https://forums.xamarin.com/discussion/21635/xforms-needs-an-itemscontrol
public class RepeaterView : StackLayout
{
    public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create(
        "ItemSource",
        typeof(IEnumerable),
        typeof(RepeaterView),
        new List<object>(),
        BindingMode.OneWay,
        propertyChanged: ItemsChanged);

    public static readonly BindableProperty ItemTemplateProperty = BindableProperty.Create(
        "ItemTemplate",
        typeof(DataTemplate),
        typeof(RepeaterView),
        default(DataTemplate));

    public event RepeaterViewItemAddedEventHandler ItemCreated;

    public IEnumerable ItemsSource
    {
        get { return (IEnumerable)GetValue(ItemsSourceProperty); }
        set { SetValue(ItemsSourceProperty, value); }
    }

    public DataTemplate ItemTemplate
    {
        get {
            return (DataTemplate)GetValue(ItemTemplateProperty);
        }
        set { SetValue(ItemTemplateProperty, value); }
    }

    private static void ItemsChanged(BindableObject bindable, object oldValue, object newValue)
    {
        try
        {
            var control = (RepeaterView)bindable;
            var oldObservableCollection = oldValue as INotifyCollectionChanged;

            if (oldObservableCollection != null)
            {
                oldObservableCollection.CollectionChanged -= control.OnItemsSourceCollectionChanged;
            }

            var newObservableCollection = newValue as INotifyCollectionChanged;

            if (newObservableCollection != null)
            {
                newObservableCollection.CollectionChanged += control.OnItemsSourceCollectionChanged;
            }

            control.Children.Clear();

            if (newValue != null)
            {
                foreach (var item in (IEnumerable)newValue)
                {
                    var view = control.CreateChildViewFor(item);
                    control.Children.Add(view);
                    control.OnItemCreated(view);
                }
            }

            control.UpdateChildrenLayout();
            control.InvalidateLayout();
        }catch(Exception e){
            throw;
        }
    }

    protected virtual void OnItemCreated(View view) =>
    this.ItemCreated?.Invoke(this, new RepeaterViewItemAddedEventArgs(view, view.BindingContext));

    private void OnItemsSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
    {
        var invalidate = false;

        if (e.OldItems != null)
        {
            this.Children.RemoveAt(e.OldStartingIndex);
            invalidate = true;
        }

        if (e.NewItems != null)
        {
            for (var i = 0; i < e.NewItems.Count; ++i)
            {
                var item = e.NewItems[i];
                var view = this.CreateChildViewFor(item);

                this.Children.Insert(i + e.NewStartingIndex, view);
                OnItemCreated(view);
            }

            invalidate = true;
        }

        if (invalidate)
        {
            this.UpdateChildrenLayout();
            this.InvalidateLayout();
        }
    }

    private View CreateChildViewFor(object item)
    {
        this.ItemTemplate.SetValue(BindableObject.BindingContextProperty, item);
        return (View)this.ItemTemplate.CreateContent();
    }
}

public class RepeaterViewItemAddedEventArgs : EventArgs
{
    private readonly View view;
    private readonly object model;

    public RepeaterViewItemAddedEventArgs(View view, object model)
    {
        this.view = view;
        this.model = model;
    }

    public View View => this.view;

    public object Model => this.model;
}

Signature Pad View does not contain getImage

$
0
0

I have use the Xamarin Control SignaturePad Form in my PCL project. The code as below:

    public class DigitalSignature : ContentPage
     {
            SignaturePadView sign = new SignaturePadView();

            public DigitalSignature()
            {
                Button btnOk = new Button
                {
                    Text = "Ok",
                    BackgroundColor = Color.FromHex("#ff6600"),
                    HorizontalOptions = LayoutOptions.End,
                    WidthRequest = 100,
                    HeightRequest = 35,
                    FontSize = 15
                };

                btnOk.Clicked += btnOk_Clicked;

                sign = new SignaturePadView()
                {
                    SignatureLineColor = Color.Red,
                    StrokeColor = Color.Black,
                    StrokeWidth = 10f,
                    HeightRequest = 150,
                    BackgroundColor = Color.White,
                    ClearText = "Clear Me"
                };
                sign.CaptionText = "pls sign here";


                Content = new StackLayout
                {
                    Children = {
                        sign,
                        btnOk
                    }
                };

            }

            private void btnOk_Clicked(object sender, EventArgs e)
            {

            }
        }

How I can get the signature as image and store in the database? In the signaturepadview do not has the getImage() function. Anyone has idea how I can do that?

Thanks,
Derick

plz help me to solve the errors

$
0
0

these are my errors in styles.xml :

Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
No resource found that matches the given name: attr 'colorAccent'.
No resource found that matches the given name: attr 'colorPrimary'.
No resource found that matches the given name: attr 'colorPrimaryDark'.
No resource found that matches the given name: attr 'windowActionBar'.
No resource found that matches the given name: attr 'windowActionModeOverlay'.
No resource found that matches the given name: attr 'windowNoTitle'.
Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.Dialog'.
No resource found that matches the given name: attr 'colorAccent'.


Object instance exception thrown when bound collection of carousel view is cleared.

$
0
0

I have a carousel view who's itemsource property is set in Xaml and the view itself is created and managed by MS Unity as a singleton. When clearing the bound collection from within the view model I get an object instance exception thrown. But on further inspection it's not the collection which is null, it's the clear method itself which is indicated as an "unknown member". The carousel page works fine on Android an Windows phone, but on iOS I receive this problem.

Xamarin.Forms 2.3.4.184-pre1

$
0
0

We've pushed Xamarin.Forms 2.3.4.184-pre1 to nuget. To install the pre-release, check the pre-release option in your nuget manager and install this version.

If you’ve got a bug to report, drop us a quick report here so we can troubleshoot in detail.

Important notes

  • Xamarin.Forms 2.3.4 depends on a Xamarin installation of Cycle 8. Users upgrading from Xamarin.Forms 2.3.3 (or earlier) will experience numerous compile errors if they attempt to build without first upgrading their Xamarin installation.

  • When upgrading Xamarin.Forms, take care not to simply "update all" as that will update the Xamarin.Android.Support packages to an incompatible version. More info here.

2.3.4.184-pre1

For all the details, please read the release post here. There is SO much goodness in this release, it's actually too long for the forum.

ColorStateList in Xamarin.Forms on C#

$
0
0

Greetings!

I am trying to create custom renderer for control (radiobutton) and need to change it's color scheme:

int[][] states = new int[][] {
    new int[] { android.R.attr.state_enabled}, // enabled
    new int[] {-android.R.attr.state_enabled}, // disabled
    new int[] {-android.R.attr.state_checked}, // unchecked
    new int[] { android.R.attr.state_pressed}  // pressed
};

int[] colors = new int[] {
    Color.BLACK,
    Color.RED,
    Color.GREEN,
    Color.BLUE
};

ColorStateList myList = new ColorStateList(states, colors);

The question is:
How can I address control states ( for ex. "android.R.attr.state_enabled" etc.) in C# ?

I am sure you know it!
Thanks in advance

Why am I can't? [assembly:Dependency(typeof( ??)]

$
0
0

I see several people use this code, but in my code I can not make it work

[assembly: Dependency(typeof(Droid.Path.Config))]

namespace Droid.Path
{
public class Config : IConfig
{

Error

Severity Code Description Project File Line
Error CS7036 There is no argument given that corresponds to the required formal parameter 'loadHintArgument' of 'DependencyAttribute.DependencyAttribute(string, LoadHint)' Droid.Path D:_DESENV\Droid\Path\Config.cs 10

Screenshoot with details and assemblies

You can help me solve this problem.
I'm using on Visual Studio 2015

THANKS

not yet resolved string was not recognized as a valid datetimev xamarin forms

$
0
0

Dear Xamarin lovers i am facing the problem to convert to datetime in xamarin forms and app crashed.
please resolve this issue.

string time="24-01-2017 07:41:27";
DateTime dt1 = DateTime.ParseExact(time, "dd-MM-yyyy hh:mm:ss:tt", CultureInfo.InvariantCulture);

System.FormatException: String was not recognized as a valid DateTime.

Thanks in Advance

RadioButton custom renderer and Click event

$
0
0

Greetings !_badPeople = _goodPeople

I have created CustomRadioButtons based on:

https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/src/Forms/XLabs.Forms.Droid/Controls/RadioButton/RadioButtonRenderer.cs
and
https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/src/Forms/XLabs.Forms/Controls/RadioButton/CustomRadioButton.cs

I styled it and it works.
But with a few issues. Please help to sort out:

  1. How to place text on the left side of radio button itself (currently I removed radio button's Texts & made separate labels on the left) ?
  2. How to change color of "halo" when pressing radio button (currently it is pink, despite the fact that radiobutton itself is blue) ?
  3. "Click" event. How can I make a handler for it or use existing one (currently just CheckedChanged available as defined in 2 classes provided above) ?
  4. The code example:

radiobutton.CheckedChanged += (sender, e) =>
{
string label = rad1.LabelId;
this.FindByName

How could I define method for ALL CustomRadioButtons, like ".CheckedChanged += (sender, e ... " ?

Looking forward for your reply
Thanks in advance!

Xamarin fan

Deploy to Android device with Visual Studio

$
0
0

Hi all,

I'm trying to migrate our Forms app from Xamarin Studio to Visual Studio Professional 2015.

Currently I want to run the app on an Android device, but all the time I build the app and press run all that happens is that
Visual Studio builds the app without errors but never deploys it to the device.

I can select Debug Any CPU the Droid project and also the device in the run menu but it's not deployed.

The console is saying Build 2 successful (iOS and Android I guess) 0 error and then
Provide 0 successful, 0 errors, 1 skipped (I expect deploying was skipped)
but why?

It always build without problems in Xamarin Studio.

Best regards


Boolean with SQLite

$
0
0

Hi everyone

According to the documentation of SQLite the data type "Boolean" isn't known and will be converted to an integer-value 1 or 0. Although my data model uses a Boolean-property.

Now when I try to query the table using LINQ I'm unable to filter to this data type.
For example, this doesn't work:

                return AsyncConnection.Table<User>()
                    .Where(x => x.Username.ToLower().Equals(lowerUsername)
                        && x.Password.Equals(password)
                        && x.IsDeleted == false)
                    .FirstOrDefaultAsync();

How am I able to filter this Boolean-property so I can use the Where-statement?

Issue with Hello, Xamarin.Forms quickstart guide. What is wrong with this code?

$
0
0

After following the Hello, Xamarin.Forms quickstart guide, I received some errors with this code from the PhoneDialer.cs in the UWP section:
`
async Task GetDefaultPhoneLineAsync()
{
var phoneCallStore = await PhoneCallManager.RequestStoreAsync();
var lineId = await phoneCallStore.GetDefaultLineAsync();

        return await PhoneLine.FromIdAsync(lineId);

}
`
Which gives me these 3 errors:
CS0246 - The type or namespace name 'PhoneLine' could not be found (are you missing a directive or an assembly reference?)
CS0103 - The name 'PhoneLine' does not exist in the current context
CS0103 - The name 'PhoneCallManager' does not exist in the current context

I have followed the guide completely, have restarted the project several times, checked dependencies, updated all existing packages & scoured the internet for a potential solution, which has as yet eluded me. Any help would be much appreciated. If any further information is required let me know.

Implement background service to download data

$
0
0

I am implementing the app in xamarin form and have download button in same to download the data
but I want to download data in background even when app is not running
How we implement the same in xamarin form in all platforms android/ios/windows phone

I keep getting XamlFilePathAttribute class not found error when modifying Xaml files

$
0
0

This attribute was introduced in November. Somehow it get's injected in my generated cs files for my xaml views but the compiler has no clue where to find the attribute. I suppose I have a versioning problem. Is it possible to get the versions where this was introduced in tools and in the libraries please?

Controlling word wrap with FormattedString / Span

$
0
0

Is there a way to control word wrap behaviour, hopefully in a xplat way, such that you can indicate a collection of Span's should be wrapped together?

For instance you might want to use a FormattedString to be arranged like:

<icon glyph> <words> <icon glyph> <words>

And logically you want the icon glyph and adjacent words to be considered one unit to be wrapped together, e.g.

[<icon glyph> <words>] [<icon glyph> <words>]

Where [ ] define the boundaries to be wrapped.

Thanks!

Viewing all 91519 articles
Browse latest View live


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