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

EventToCommand with Xamarin Forms Behaviors

$
0
0

I wrote an EventToCommand behavior using Xamarin Forms 1.3 behaviors and I would like to share it with you : anthonysimmon.com/eventtocommand-in-xamarin-forms-apps/

You will find an example where the EventToCommand is bound to the ItemTapped of a ListView so that we can get the tapped item data context inside a command of the ListView data context:

<ListView ItemsSource="{Binding People}">
  <ListView.Behaviors>
    <b:EventToCommandBehavior EventName="ItemTapped" Command="{Binding SayHelloCommand}" EventArgsConverter="{StaticResource ItemTappedConverter}" />
  </ListView.Behaviors>
  <ListView.ItemTemplate>
    <DataTemplate>
      <TextCell Text="{Binding Name}"/>
    </DataTemplate>
  </ListView.ItemTemplate>
</ListView>

Master Detail Issues in Android But Working in iOS

$
0
0

Hi ,

I used below code for Master Detail Scenarios but it's working in iOS, But in Droid platform getting below Error message that Android only allows one navigation page on screen at a time using

From Home screen to below screen navigation I'm using below code :

`listView.ItemSelected += async (sender, e) =>{

            if (e.SelectedItem != null) {
                //do what you want with the selectedItem
                // Navigation with back push
                await Navigation.PushAsync (new LeadViewController ());
            }

            //then init the selectedItem of the listview to enable it to be selected again
            listView.SelectedItem = null;
        };`

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

namespace eMO_Xamarin
{
public class LeadViewController : MasterDetailPage
{
public LeadViewController ()
{
this.BackgroundImage = "Bg6.jpg";

        var menuPage = new MenuPage ();
        menuPage.OnMenuSelect = (categoryPage) => {
            Detail = new NavigationPage (categoryPage);

            if (Device.Idiom == TargetIdiom.Phone) {

                IsPresented = false;

            } else if (Device.Idiom == TargetIdiom.Tablet) {

                IsPresented = true;

            } else {

                IsPresented = false;
            }
        };

        Master = menuPage;

        Detail = new NavigationPage (new LetsGetStartedPage ());

        MasterBehavior = MasterBehavior.Split;
    }

}

}`

Can we Override the properties of ImageCell using Forms or through Rendering?

$
0
0

In ImageCell, the detail text is limited to only one line and the LineBreak Mode is Tail truncation by default.

I'm trying to set the number of lines of Detail text to 2.

How this can be achieved? Please help!!

iam having eventargs error Severity Code Description Project File Line Suppression State Error CS03

$
0
0

iam having eventargs error

Severity Code Description Project File Line Suppression State
Error CS0308 The non-generic type 'EventArgs' cannot be used with type arguments 87 Active
can you plz help me with this

How to add a progress bar while calling a web service and get the value from it.

$
0
0

I'm willing to add a progress bar after click of the button which is used to fetch the data from web service and the bar will continue till the values get rendered on screen.

How to do that?

Failed to resolve "System.Void CoreGraphics.CGRect..." Reference from "Xamarin.iOS..."

$
0
0

all of a sudden I am getting this error, after upgrading xamarin.form in visual studio, then I downgrade it, but the error remains, I tested other Xamarin projects, they are working fine, I do not really understand how the reference to CoreGraphics.CGRect failes here

please give me a hand here, been working on this project every day, can't proceed without solving this issue at the moment

image

Xamarin Forms v2.0.1.6505 - Exception when targeting x64 in UWP project

$
0
0

Hi,
I have created a new solution based on the cross-platform (portable) template and updated it to XF version 2.0.1.6505.

When I select the UWP project and change the platform target to x64, the solution builds correctly but I get the following exception when application is launched:
System.NotImplementedException was unhandled by user code
HResult=-2147467263
Message=The method or operation is not implemented.
Source=Windows
StackTrace:
at Windows.UI.Xaml.Setter.get_Value()
at Xamarin.Forms.Platform.UWP.WindowsResourcesProvider.GetStyle(Object nativeKey)
at Xamarin.Forms.Platform.UWP.WindowsResourcesProvider.GetSystemResources()
at Xamarin.Forms.Application..ctor()
at App9.App..ctor()
at App9.UWP.MainPage..ctor()
at App9.UWP.App9_UWP_XamlTypeInfo.XamlTypeInfoProvider.Activate_4_MainPage()
at App9.UWP.App9_UWP_XamlTypeInfo.XamlUserType.ActivateInstance()
InnerException:

All works properly if I select the x86 target.

Thanks,
Davide

How to add control only for iOS in grid

$
0
0

Hi,

I want to add a control only for iOS in grid. can any one give me the example please.


Text capitalization in the XAML

$
0
0

Hello,

I have a field where the user can write postal code. I want to receive the postal code in uppercase, so I capitalize it. Does Xamarin.Forms have any method to capitalize the text directly in the XAML code? I make it in the C# for now, but I want to move it to XAML if it is possible.

Thanks in advance.

Http File Upload / Download with Progress

$
0
0

I have several local files (mostly photos) I need to upload over 3G (or download to another device) and would like to provide a progress to the user while it's happening.

I'm currently using (await) HttpClient.PostAsync or GetByteArrayAsync but can't figure out how to get the progress.

Pointers to what I'm overlooking would be most appreciated! :)

How to access a folder via code that is added to the Xamarin Forms project.

$
0
0

I am writing a XamarinForm App. I have a folder inside each project (ios and Android) that has some data. I want to be able to get to the path of the folder added to the project. I need to access the entire folder and not just one file from it. So I can't really set it as Embedded Resource. Any ideas? I couldn't find a straightforward way of accessing it that is common to all platforms. For iOS I resorted to following, but have no success on Xamarin Android Yet. Any help or pointers are appreciated. Thanks.

if IOS

    var strFolderPath = NSBundle.MainBundle.BundlePath;
    var compactCache =Path.Combine(strFolderPath, "NorthAmericaCacheV1/Layers");

endif

if ANDROID

//Can't figure out what to do :-(

endif

Load an image on the screen

$
0
0

For the life of me, I can not get a simple image to show up on the phone. I'm debugging with a Galaxy S5. Here's my code:


The label shows up. The button shows up. The image does not.

I have added img1.png to the drawable folder in the Android project.

Screen Shot: http://screencast.com/t/hEElQBar

I have also tried setting the Source="img1". Nothing ever seems to load the image.

How to Push NavigationPage in TabbedPage

$
0
0

Hello,

I have a TabbedPage as my MainPage with 3 Children NavigationPages.

On one ChildPage I have a ListView. Now when I click in one item I want to open a DetailPage with a back button in the top left and I don't want to see the three Tabs.

When I use PushModalAsync I nearly have this behaviour but without an back Button on top left. And yes I use a NavigationPage.

Does anyone have a solution for my problem?

Thanks.
Markus

Button Clicked event fired twice when only pressed once

$
0
0

I'm trying to create my first app, it's kind of a copy of the Tasky demo app, but with some custom features. I'm running into a problem that I don't really understand.

This is my XAML form:

<?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="EasyNotes.UI.NewNotePage">
  <ScrollView>
    <StackLayout>
      <Label Text="Title"/>
      <Entry x:Name="entryTitle" Placeholder="Type the title here"/>
      <Label Text="Description"/>
      <Editor x:Name="editorDescription" HeightRequest="150"/>
      <Button x:Name="buttonSave" Text="Save" Clicked="buttonSave_Clicked"/>
    </StackLayout>
  </ScrollView>
</ContentPage>

This is the code behind:

public partial class NewNotePage : ContentPage
    {
        public NewNotePage()
        {
            InitializeComponent();

            buttonSave.Clicked += buttonSave_Clicked;
        }

        public void buttonSave_Clicked(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(entryTitle.Text) || string.IsNullOrWhiteSpace(editorDescription.Text))
            {
                DisplayAlert("Alert", "All fields are required.", "OK");
            }
            else
            {
                Note note = new Note();

                note.Title = entryTitle.Text;
                note.Description = editorDescription.Text;
                note.DateAndTime = DateTime.Now;
                note.IsActive = true;

                NoteFactory factory = new NoteFactory();

                bool isSaved = factory.AddNewNote(note);
                if (isSaved)
                {
                    DisplayAlert("Alert", "Note saved sucessfully.", "OK");
                }
                else
                {
                    DisplayAlert("Alert", "Note was not saved.", "OK");
                }

                Navigation.PopAsync();
            }
        }
    }

When I press the buttonSave the buttonSave_Clicked method it's called twice and my Note object it's saved duplicated to the database. I find strange that when I'm debugging this piece of code the DisplayAlert doesn't show on the first time and after the code run for the second time it shows again, instead both alerts are displayed consecutively in the end, after the second run.

Any ideas on why this is happening and what do I need to change in order to make it work?

Get progress of my upload with Imgur.net nuget

$
0
0

Hey

I use this nuget imgurapi.readthedocs.io/en/latest/ to upload my image to imgur with Xamarin.Forms.

I want to get my upload progression.

This is my code :

public async Task UploadImage(Stream source)
{
    var client = new ImgurClient(ConstantKeys.ImgurClientId, ConstantKeys.ImgurClientSecret);
    var endpoint = new ImageEndpoint(client);

    try
    {
        var image = await endpoint.UploadImageStreamAsync(source);

        var link = image.Link;
        ImageLink = link;
        _clipboardService.CopyToClipboard(link);
    }
    catch (Exception ex)
    {
        Debug.WriteLine(@"/!\ DEBUG - UploadImage method : " + ex.Message);
    }
}

The owner link me this tutorial, but i never worked with Progress, and i need help:
https://blogs.msdn.microsoft.com/dotnet/2012/06/06/async-in-4-5-enabling-progress-and-cancellation-in-async-apis/

Any suggestion ?

Thank you


How to launch the app from SMS content (link or button)

$
0
0

Hi there
I'm trying to implement the code launching the app have been already installed on the device. The scenario is as follows.
1. User receives an SMS
2. SMS reads an information but for details the use has to hit a link or button to launch the app
My question is what that link should have as OnClick event handler?
If there is a solution for Forms - that's just perfect. Otherwise, could anybody give me an idea for both Android and iOS?
Thanks.

Handle Push Notifications on iOS / Forms

$
0
0

Hello,

I'm trying to handle and show a notification on ios depending on a type.

For it I'm using a Silent Remote Notification to trigger the ReceivedRemoteNotification method on AppDelegate.

In the Alert parameter of my notification I send a json with parameters message and type.

here is what it looks like:

    public override void   ReceivedRemoteNotification(UIApplication application,NSDictionary remoteNotification)
            {
                if(remoteNotification != null)
                {
                    string message = remoteNotification["alert"]["message"];
                    string type = remoteNotification["alert"]["type"];

                    //if(type=="notification")
                    //Show notification with alert = message, badge = 1 and etc...


                }
            }

Now my problem begins...

How can I create a notification as it would show for a normal remote notification?

I know I can show an alert or something but in this case the app will stay in background. It will only be waked up to trigger the ReceivedRemoteNotification method.

I got this idea from this topic

Is it possible?

Initializecomponent does not exist in the current context

$
0
0

Hi ,
I have updated my Xamarin Studio and Xamarin.Forms to 1.4.0.0, now when ever creating Xaml Page in portable
application , i'm getting build error as "Initializecomponent does not exist in the current context".Does any one faced this issue

Thanks in Advance

The name 'InitializeComponent' does not exist in the current context on an Android project

$
0
0

Hello, I'm having issues on building android app - it fires this error on all pages. But building ios app goes fine. I've tried to build this project on windows and got the same error. Unfortunately what caused it I don't remember.
What can cause this error?

System.MissingMethod Exception after upgrading to Xamarin Forms 2.2.043 on Xamarin Studio Mac

$
0
0

After upgrading to the new version of Xamarin forms I'm getting a System.MissingMethod exception. Help!!!!!!!!!imageimage

Viewing all 58056 articles
Browse latest View live


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