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

How do I make a "gallery" page with many images fitting in, in this special way shown in the desc :)

$
0
0

How do I make a page like this? And in addition I want to have white text in the middel of the images.


Permission Denial: not allowed to send broadcast android.location.GPS_ENABLED_CHANGE

$
0
0

This code is not working for Turn on Location

Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
                intent.PutExtra("enabled", true);
                SendBroadcast(intent);

Is there any Floating Video Player for Xamarin.Forms or Xamarin Android & IOS?

$
0
0

Is there any Floating Video Player for Xamarin?

Thanks in advance

Opening a ZXing.net scanner page with user input before

$
0
0

Hi everyone,

I'm running into an issue that I can't quite seem to figure out. I have a xamarin.forms application where i'm using the Zxing plugin to scan a QR code. I have an async event i'm firing on a button press to ask a user a question, then pass the answer to the scanner page:

buttonScan.Clicked += Scan;

private async void Scan(object sender, EventArgs e)
{
string answer = await DisplayActionSheet("Question", "Cancel", null, "Type 1 (Non Valid)", "Type 2", "Type 3");

        switch (answer)
        {
            case "Cancel":
                await Navigation.PopToRootAsync();
                break;
            case "Type 1 (Non Valid)":
                answer = "Type 1";
                break;
        };

        await Navigation.PushAsync(new ScannerPages.Scan(answer));
    }

When I execute this way, the scanner page comes up as expected, but no scanning occurs, like it isn't active or something. However, if I instead set string answer = "Type 1" instead of displaying an action sheet, it works as expected. What am I missing here? Have I done something wrong with the asynchronous bit?

How do I properly bind to a label's span?

$
0
0

I have a label that looks something like this:

<Label x:Name="MovAvgLabel" Grid.Column="0" HorizontalOptions="Center" HorizontalTextAlignment="Center" >
                            <Label.FormattedText>
                                <FormattedString>
                                    <Span Text="{Binding Path=MovingAverage}" FontSize="Medium" FontAttributes="Bold"/>
                                    <Span Text="&#10;Moving Average&#10;Today"/>
                                </FormattedString>
                            </Label.FormattedText>
                        </Label>

The above code fails to bind to my ViewModel. I don't think it's the binding context, I tried binding to a regular label like so:

<Label Grid.Column="0" HorizontalOptions="Center" HorizontalTextAlignment="Center" Text="{Binding MovingAverage}"/>

And that seemed to work fine. What am I doing wrong here? The two examples shared the same grid parent. What's weird is that I've bound objects to spans before and it worked fine, although it was in the context of a custom ViewCell so maybe there's some weirdness there.

Xamarin Forms Previewer Not available

$
0
0

I'm using VS2017 Community and I keep seeing things about Xamarin Forms Previewer but I don't see it anywhere when trying to view my form.

is it not available on the community edition? did they ditch it for something else? I'm lost and frustrated.

I don't have access to a mac at the moment so is that possibly a problem?

I'd greatly prefer to not have to build and run to make sure everything looks right, especially when I'm new to xamarin forms

I need a SQLite library for Xamarin forms that supports writing dynamic SQL, not LINQ etc.

$
0
0

Hi,
I need a SQLite library from my Xamarin Forms/.NET Standard app that supports executing dynamic SQL queries including the result sets (columns returned can vary).

The nuget package "sqlite-net-pcl" only support ORM API's where I need to declare static C# classes that map to the SQLite schema.

There appears to be a low level SQLitePCLRaw library. Is this the only option for SQLite apps that want to get data back not bound to LINQ or C# classes?

Tabbed Page tab reselected

$
0
0

I've been looking for a solution to this problem for a few days and I think I've exhausted all of the old posts and articles on the topic without finding a solution. For Android specifically I've tried a custom renderer that uses TabLayout.IOnTabSelectedListener.OnTabReselected but it seems the event is never fired or even referenced anywhere.

How do you detect when a tab is reselected on a tabbed page? By reselected I mean the button of the tabbed page tab you are currently on is pressed while you are still on that tab. I need this in order to do a page "refresh". Thanks in advance!


Why Am I Getting Null Reference Exception When Using .Contains Method

$
0
0

Hi. I am trying to know if an ObservableCollections contains a specific Object but I continuously get this error :

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object. occurred.

Here is part of the code I am using to test the condition:

            if (collection.Contains(new Contact { FirstName = "Dyary", LastName = "Raoof"}))
                {

                 }

collections is the obervableCollection of Contac objects that I am trying to test .
thanks

How to implement only emoji keyboard for Entry?

$
0
0

Please help me to implement Custom Entry (Xamarin.forms) when the user focus the Entry, device will show Emoji keyboard.

Change a BindingContext of a ListView back from the Model to the ViewModel

$
0
0

I’ve got a a ContextPage and I’m trying to get a BindingContext in the StackLayout that is currently on a Model on a Switch (or the behavior on the Switch) back to a ViewModel.

I’ve tried to set the BindingContext from the Model back to the ViewModel, but I’ve been unable to do that either by the XAML or the code behind.

I'm using 2017 Mac Visual Studio .Net standard 2.0 project with NuGet Behaviors.Forms v1.4.

XAML:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:behaviors="clr-namespace:Behaviors;assembly=Behaviors"
             x:Class="ParentChild.Views.ViewTeamAdd"
             xmlns:local="clr-namespace:ParentChild;assembly=ParentChild"
             Title="Create a new Team">
    <StackLayout Padding="10">
..Unneeded items removed… 
            <ListView.ItemTemplate>    
                <DataTemplate>    
                    <ViewCell>
..Unneeded items removed… 
                            <Switch x:Name="MyToggle" Grid.Row="0" Grid.Column="0" HorizontalOptions="Start" >
                                <Switch.Behaviors>
                                    <behaviors:EventHandlerBehavior EventName="Toggled" x:Name="MyToggleEventBehavior" >
                                        <behaviors:InvokeCommandAction 
                                            Command="{Binding BindingContext.TogglePlayerCommandWithParameterCommand}" 
                                            CommandParameter="{Binding Id}"/>
                                    </behaviors:EventHandlerBehavior>
                                </Switch.Behaviors>
                            </Switch>
..Unneeded items removed… 

The Entire XAML is here

XAML code behind:

    public partial class ViewTeamAdd : ContentPage
    {
        private ViewModelTeamAdd viewModel;
        public ViewTeamAdd()
        {
            InitializeComponent();
            BindingContext = viewModel = new ViewModelTeamAdd(Navigation);
        }
    }

Full code behind class file

I’ve tried to set the BindingContext in the XAML and gotten nowhere. I’d rather do it in the XAML, but I need to get this to work in one way or another; so I’ll be happy to get it to work in code behind.


I’ve tried the below and received an cs1061 errors on all.

            Behavior _behavior = this.MyToggleEventBehavior;

            Switch _switch = this.MyToggle;

            this.MyToggle.BindingContext = viewModel;


I’ve tried with and without this and it doesn’t matter - still getting the same cs1061 [XamlCompilation(XamlCompilationOptions.Compile)]

When debugging, I’ve found the below FindByName returns null.

            this.FindByName<Switch>("MyToggle")
            this.FindByName<Behavior>("MyToggleEventBehavior")


A link to the repo

If someone has any thoughts on how to get around this, I would really appreciate it.

Play videos with protections

$
0
0

In my project I must play some video with protections:

  • PlayReady
  • Widevine
  • AES

How can I do that? Thank you in advance

TabbedPage Performance / Replacing Current Page?

$
0
0

Hello,

Firstly, some background: We have a requirement within one of our apps to show multiple different pages side by side using Xamarin Forms where you can swipe between pages and quickly jump to a particular page. This app is currently targetted for Android.

TabbedPage appears to do exactly what we want, however the problem we have is performance. As TabbedPage implements MultiPage when you setup the tabs, you have to setup all the Page objects at the same time.

This however can be very slow if there are some complex layouts / large number of elements on the Page in question, e.g. in some cases we can see for 10 tabs it taking around 5seconds to setup all the pages. (and we want it to be far snappier than that)

Ideally what we would like is that the Page is only instantiated when it first appears, I thought of 2 simple options:

Option 1 - Override the implementation of TabbedPage

Unfortunately this doesn't seem possible, as TabbedPage implements MultiPage and some of the code isn't accessible as it uses EditorBrowsable(EditorBrowsableState.Never), it doesn't look we can override the necessary bits to have the tabs detached from the actual Page objects.

Option 2 - Tab Page objects replace itself on appearing

One idea I had was that we create a simple implementation of Page that has no components, and simply has a Func<Page> which when appearing it calls to create the actual page, then replaces itself in the parent TabbedPage. The setup of the TabbedPage even with large numbers of pages is then quick as they are all blank.

Although not an elegant solution, this actually works quite welll, however we run into another issue: Lets say we have a <LoadPage> which when it appears we are replacing with <ActualPage>, for this to work we need to:

  1. Update the TabbedPage Children array to replace the <LoadPage> with the new <ActualPage>
  2. Ensure the TabbedPage CurrentPage points to the <ActualPage>

However we then have a chicken and egg situation, if you change the Children first, this immediately triggers the CurrentPage to unset as the <LoadPage> is no longer in Children, which will cause the display to scroll the tab control to the first tab. Then when setting the CurrentPage to <ActualPage> this then correctly moves to the required tab. Essentially, this causes a huge jittering on the display as it scrolls to the first tab and back again, which looks really clunky.

If you try and change the CurrentPage first to <ActualPage> before that page has been replaced in the Children, it knows and unsets the CurrentPage immediately.

Essentially, I really need a method to replace an item in the Children and set CurrentPage at the same time, but as this is within the MultiPage class, it seems I have no control over this.

So my question is does anyone here have any suggestions or better ideas when trying to use TabbedPage or something like it to achieve the same result, where I can instantiate the Page on its first appearing rather than up front when we setup all of the tabs. (or do I just need to plead with Xamarin dev team to see if they can add more flexibility to the TabbedPage implementation?)

MrMoo

Accepting a credit card payment in my app

$
0
0

I just installed the NuGet package Authorize.NET in my Xamarin.Forms app, but it looks like it won't work with iOS and Android in a Xamarin project. Is there a simple API I can use in my shared app to enable processing a credit card payment in my Xamarin.Forms shared project? The user will simply enter their credit card information into a form and I will bill their credit card using my merchant account/credit card processor.

Thanks,
Jay

Xamarin.Forms require msbuild

$
0
0

Hi,
I update Xamarin Forms to Xamarin.Forms 3.0.0-pre3 and I get this error
Xamarin.Forms require msbuild. xbuild is no longer supported.

I need help please.


Xamarin.Forms: Changing TabbedPage tab icons depending on active/inactive

$
0
0

Hey guys!

I'm working on a Xamarin.Forms project and I'm trying to change the icons of the TabbedPage tabs depending on whether the tab is active or inactive. I have gotten it to work on iOS with the following code, but for some unknown reason it doesn't work on Android.

MainPage.xaml

<TabbedPage xmlns:Views="clr-namespace:Project.Views" x:Class="Project.Views.MainPage">
    <NavigationPage x:Name="HomeTab" Title="Home" Icon="home_inactive.png">
        <x:Arguments>
            <Views:Home/>
        </x:Arguments>
    </NavigationPage>
    <NavigationPage x:Name="FavoritesTab" Title="Favorites" Icon="favorites_inactive.png">
        <x:Arguments>
            <Views:Favorites/>
        </x:Arguments>
    </NavigationPage>
    <NavigationPage x:Name="AlertsTab" Title="Alerts" Icon="alerts_inactive.png">
        <x:Arguments>
            <Views:Alerts/>
        </x:Arguments>
    </NavigationPage>
    <NavigationPage x:Name="AccountTab" Title="Account" Icon="account_inactive.png">
        <x:Arguments>
            <Views:Account/>
        </x:Arguments>
    </NavigationPage>
    <NavigationPage x:Name="TestViewTab" Title="TestView">
        <x:Arguments>
            <Views:TestView/>
        </x:Arguments>
    </NavigationPage>
</TabbedPage>

MainPage.xaml.cs

public partial class MainPage : TabbedPage
{
    public MainPage()
    {

        InitializeComponent();

        this.CurrentPageChanged += (object sender, EventArgs e) => {

            var i = this.Children.IndexOf(this.CurrentPage);

            HomeTab.Icon = "home_inactive.png";
            FavoritesTab.Icon = "favorites_inactive.png";
            AlertsTab.Icon = "alerts_inactive.png";
            AccountTab.Icon = "account_inactive.png";

            switch (i)
            {
                case 0:
                    HomeTab.Icon = "home_active.png";
                    break;
                case 1:
                    FavoritesTab.Icon = "favorites_active.png";
                    break;
                case 2:
                    AlertsTab.Icon = "alerts_active.png";
                    break;
                case 3:
                    AccountTab.Icon = "account_active.png";
                    break;
            }

        };

    }

}

Using the CurrentPageChanged event works perfectly for iOS, but for some reason it doesn't work on Android. If I change something like Title instead of Icon, then it'll work on both iOS and Android.

How would I go about fixing this so it works on both Android and iOS? Can I do it all in shared code? If not, could someone walk me through creating platform specific code to do the job?

I would very much appreciate if you guys could help me out! Thanks in advance!

View to expand its own width based on children count

localhost in emulator genymotion => Bad Request

failed to install app in Xamarin Forms?

$
0
0

I have developed a simple application in Xamarin forms. It is running properly on android emulator in my PC.
I have archived the android project and generated apk for that however it is not installing in my android phone. The error message is

failed to install the app

I have mostly used the default configuration values while building the app and archiving.
Only these are the configuration which I have changed:
1. Inside Android Option Unchecked the Use Shared the runtime.
2. and in Linking changed none to Sdk assemblies only.
3. Configuration is Debug and platform is Active(Any CPU). Although I tried installing app with all three value including Debug, Release, Active(Debug) but none of them installed.
What is wrong here?

API http://localhost:port/api/.... & http://pokeapi.co/api/v2/pokemon/3/

Viewing all 77050 articles
Browse latest View live


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