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

how to close app

$
0
0

Hi,
How to close app on forms? Thanks


How to get Image from HttpClient

$
0
0

I'm trying to download an image from a url using HttpClient

HttpClient client = new HttpClient();
client.MaxResponseContentBufferSize = 256000;
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tocken);

Image img = new Image();
img.Source = ImageSource.FromStream(await client.GetStreamAsync(url));

return img;

But it gives me the error

cannot convert from 'System.IO.Stream' to 'System.Func<System.IO.Stream>'

How can I solve this problem?

How to ensure an element is 10cm long?

$
0
0

Hello,

I have been tasked with generating a research app that uses the Visual Analogue Scale (VAS). This is a scale used to monitor trends in pain levels in patients over a period of time (for example, whilst Patient Controlled Analgesia is being used). In order for the research results to be reliable, the presented scale in the app must fulfil universal criteria. One of these is to ensure the scale is exactly 100mm (10cm) long.

I was considering using simple BoxViews to present this line.

My question is how does one ensure that a presented element (i.e. the line) is exactly 10cm long across a variety of devices? Obviously, this assumes that the device screen width is >10cm itself.

I would be grateful for any advice on this.

Thanks!

How to display weather icon in xamarin by calling Openweather API?

$
0
0

I have 3 Tabbed Pages. Header of the Page will have the current location, temperature and the icon. I am using OpenWeather to retrieve the Current Coordinates Weather and it's icon.

I am able to bind the image in the content page. However, i couldn't able to bind the image in Header.

How should i do this ?

Syntax to call the Tabbed Page.





Working on existing SQLite Database ?

$
0
0

I am working on an early stage of an App. At present, I am using a sqlite database which is created separately and attached to the App from Resources. On every Insert, Update, data stored in the database doesn't exist forever. It remains until the app is running. SQLite to server database sync up is not yet started to code.

Is this because, we are attaching the db directly to app and not generating from the code ? Whether generating from the code will have better performance?

Formatted Label with Xamarin.Forms

$
0
0

Can someone please show me how to use Xamarin.Forms.Label.FormattedText correctly?

I'm using Xamarin.Forms to write a Carousel based app, when I try

Label IntroductionTextLabel = new Label();
IntroductionTextLabel.FormattedText = "Test";

I get this error:

"'Xamarin.Forms.Label' does not contain a definition for 'FormattedText' and no extension method 'FormattedText' accepting a first argument of type 'Xamarin.Forms.Label' could be found (are you missing a using directive or an assembly reference?)"

Perhaps it's the version of Xamarin I'm currently using...

The next step would be using this to display some HTML.

Thanks for any help.

Does UWP project in Xamarin.Forms check the size of itself Automaticly?

$
0
0

I am adding an UWP project into my Xamarin.Forms solution. There is a exception:
"#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};

endif"

The message is
"Message = "System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.\r\n at Windows.UI.Xaml.UIElement.Measure(Size availableSize)\r\n at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.MeasureOverride(Size availableSize)

When I change the "Grid.RowSpan" of some controls, the exception just gone.

By the way, there is no exception when the app runs in local Machine, it just occurs in Windows Mobile.

Is this something about size?

Windows phone 8.1 with database not save database after close phone

$
0
0

I am working with xamarin forms and when running the application on windows phone emulator then close the emulator the database is destroying and I have to recreate the data every time I am lunching the emulator.

Database connection code:
public class SQLite_WindowsPhone : ISQLite
{

            public SQLite_WindowsPhone()
            {
            }

            public SQLiteConnection GetConnection()
            {
                var sqliteFilename = "dataBase.db3";
                string documentsPath = ApplicationData.Current.LocalFolder.Path;
                var path = Path.Combine(documentsPath, sqliteFilename);

                // Create the connection
                var conn = new SQLiteConnection(path);
                // Return the database connection
                return conn;
            }
        }

ContextAction MenuItem icon not showing in iOS

$
0
0

I'm developing PCL based solution using Xamarin.Forms. I added ContextAction to listview. I have delete MenuItem with trash icon in ContextActions. The trash icon not showing in iOS not platform.But in android its working fine. the iOS not support MenuItem icon?
My XAML code is
<ViewCell.ContextActions>

<MenuItem Clicked="OnDeleteMenu" Icon="dustbin.png" Text="Delete" IsDestructive="true" CommandParameter {Binding .}" />
</ViewCell.ContextActions>

i am using latest Xamarin.Forms.Please Anyone give the solution

Thanks,
Mahabaleshwar Hegde

Switch in UWP

$
0
0

I am adding an UWP project into xamarin.Forms.

I found that the switch is different from that in iOS and Android. There is a text like "On" or "Off" behind the control.

How to hide that?

MasterDetailPage Fixed icon menu

$
0
0



Hi, they have some idea how to leave the icon of the hamburgesa fixed, while navigating to the pages of the menu, of my main page, the images illustrate a little the effect that I want to bind instead of the icon to return back. That is the one of the hamburger.

Thanks in Advance

Removing fody from Xamarin.Forms

$
0
0

I have been using Realm and Fody with my Xamarin.Forms project however decided to switch to SQLite. Removing everything related to realm and fody I came across this when I was done.

Fody: No configured weavers. It is possible you have not installed a weaver or have installed a fody weaver nuget into a project type that does not support install.ps1. You may need to add that weaver to FodyWeavers.xml manually. eg. . see https://github.com/Fody/Fody/wiki/SampleUsage

Why is this still a thing? I'm so confused there is no more reference to fody that im aware of.

Do LayoutOptions work with RelativeLayout in XAML?

$
0
0

I am trying to do a very simple layout test for a XAML implementation of RelativeLayout with LayoutOptions specified for the controls on the page (which should be possible, as far as I understand, since they also inherit from the View class). Please see the below XAML and let me know if there are just problems with it, but if there are no problems, please tell me whether or not RelativeLayout supports LayoutOptions.

Also, I understand that I can use X and Y Constraints or Height and Width Contraints to define these boundaries and positions, but for simple positioning of controls, I would rather use the LayoutOptions while still maintaining the use of a RelativeLayout (rather than a simpler StackLayout) for more advanced positioning when I want it.

    <?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:AppName.ViewModels;assembly=AppName"
                 x:Class="AppName.Pages.HomePage"
                 Title="AppName">
      <ContentPage.BindingContext>
        <local:HomePageViewModel />
      </ContentPage.BindingContext>
      <RelativeLayout Padding="15" VerticalOptions="StartAndExpand" HorizontalOptions="StartAndExpand">
        <Label x:Name="MainText"
               Text="{Binding MainText}"
               VerticalOptions="End"
               HorizontalOptions="CenterAndExpand">
        </Label>
      </RelativeLayout>
    </ContentPage>

Any insights are appreciated. Thanks!

iOS debug deployment failing

$
0
0

I'm seeing an error after I try deploying my iOS build to a simulator on my mac machine (via Xamarin Mac Agent) which I remote in to

It built, deployed, executed, and the debugger attached successfully.
I terminated it.
The next time and all subsequent attempts, I get the following error. The app does not get deployed (it is not present on the simular)

Launching 'App.iOS' on 'iPhone 6 iOS 10.2'...
Launch failed. The app 'App.iOS' could not be launched on 'iPhone 6 iOS 10.2'. Error: The post for client vs4064jwier on topic xvs/idb/4.2.1.64/launch-app has been cancelled. Please check the logs for more details.
The app has been terminated.

Webview can't load html file

$
0
0

Hi all,
Currently I try to load the html file , after I debug, it does not shown anything.


Unexpected behavior on UWP with Task.Delay

$
0
0

Greetings,

I wrote a method that should always take 1 second but for UWP it takes 1 and a half. This does work as expected for Android though.

    public async Task MeasureTime(string s)
    {
        var interval = 10;
        var old = DateTime.Now;
        var expectedTimeSpent = TimeSpan.Zero;

        for (int i = 0; i < 100; i++) {
            await Task.Delay(interval);
            expectedTimeSpent = expectedTimeSpent.Add(TimeSpan.FromMilliseconds(interval));
        }

        var actualTimeSpent = DateTime.Now - old;

        Debug.WriteLine(expectedTimeSpent.TotalMilliseconds);
        Debug.WriteLine(actualTimeSpent.TotalMilliseconds);
    }

Results:
- 1000
- 1554.9964

Can anyone explain to me why this is? Is this something Windows specific?

sss

Which library to use with Notification Hubs (and what tutorial to follow?)

$
0
0

I'm trying to quickly get push notifications to work for my XF Forms app, but there's tons of "official" tutorials around on how to use Notification Hubs, which talk about different approaches.

There's this tutorial here at the Azure docs:
https://docs.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-xamarin-forms-get-started-push

This tells me to search for the Google Cloud Messaging Client in the component store.
That's this 3rd party library herehttps://components.xamarin.com/view/gcmclient/
This hasn't been updated here on the store since 2013, so this appears to be utterly obsolete.
To make things worse, this also is the article that is linked to from the Xamarin website here:
https://developer.xamarin.com/guides/xamarin-forms/web-services/push-notifications/azure/


The Xamarin Evolve app uses the Microsoft.WindowsAzure.Messaging.Android library from the Components store. This hasn't been updated in months, with some unanswered feedback about bugs. Not sure about this one.
Tutorial: https://docs.microsoft.com/en-us/azure/notification-hubs/xamarin-notification-hubs-push-notifications-android-gcm
Component: https://components.xamarin.com/view/azure-messaging


Then there's the messaging component from Xamarin: https://www.nuget.org/packages/Xamarin.Firebase.Messaging/
This has a hard dependency on Xamarin.GooglePlayServices.Basement (= 32.961.0), which sends me straight to dependency hell because XF Forms Maps still depends on 29.0.0.1, which is like 20 years old now.


Then the Azure docs talk about "Mobile Apps Client SDKs" that would simplify stuff. I have no idea what kind of library they are talking though. The Azure client library doesn't seem to contain anything regarding notification hubs on the client side:
https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-push-notification-overview#integration-with-app-service-mobile-apps

To make things more confusing, there's a lot of articles that explain how to do things in different ways, many of them outdated with broken links.
I'm really at a loss here - and I think there should be an effort to make a piece of official and updated documentation easily retrievable for developers. After all, this is a super common thing for a mobile app.

Any guidance to updated documentation is appreciated.

Thanks,
Philipp

How to show item attributes in a ListView with ViewCell?

$
0
0

Hello, I have the following code as my XAML template for listing some items in a list:

`

  <ListView.Header>
    <StackLayout Padding="10,5,0,5" BackgroundColor="#bbbbbb">
      <Label Text="{Binding name}" FontSize="Small"/>
      <Label Text="{Binding user}" />
      <Label Text="{Binding creationDate, StringFormat='created on {0:d} {0:T}'}" />
    </StackLayout>
  </ListView.Header>

  <ListView.ItemTemplate>
    <DataTemplate>
      <ViewCell>
        <ViewCell.View>
          <Label Text="item" FontSize="Medium"/>
        </ViewCell.View>
      </ViewCell>
    </DataTemplate>
  </ListView.ItemTemplate>

  <ListView.Footer VerticalOptions="End">
    <StackLayout Padding="10,5,0,5" BackgroundColor="#bbbbbb">
      <Label Text="{Binding items.Count, StringFormat='{0} items'}" FontSize="Small"/>
    </StackLayout>
  </ListView.Footer>

</ListView>

`

the ItemsSource, items, includes 5 items. The objects of items are of this class:

`
public class ShoppingListItem
{
public Product product;
public bool crossed;
public string keyword;
public int quantity;
public string unit;

    public ShoppingListItem()
    {
        quantity = 0;
        crossed = false;
        product = null;
        keyword = null;
        unit = null;
    }
}

`

When I execute the page, I see exactly 5 "item" labels on the list.
For debugging purposes, I display an alert with the item's keyword whenever that item is selected. It's successfully displayed.
However, I can not display the keyword itself on the list instead of the "item" word. I'm almost sure it's XAML related, but I don't know how to do it.
I have tried all sorts of combinations, and I could not.

Is there a specific content in ItemTemplate? What should I type in text field of the Label to get the item name?

Thanks a lot. I'm in sort of a hurry with this, so any help is greatly appreciated.

Xamarin.Forms for UWP Preview Now Available

$
0
0

Update
For Xamarin.Forms 2.0, the UWP preview is included in the Xamarin.Forms NuGet package. Be sure to read the directions here to get started:

https://developer.xamarin.com/guides/cross-platform/xamarin-forms/windows/getting-started/universal/

Old thread, do not follow
Many in our community have been asking about Xamarin.Forms for Universal Windows Platform support, and today, we are very happy to bring that request to life. In the past, building apps with Xamarin.Forms required you to create a separate Windows Phone and Store applications, but this preview, available to try today, will enable you to target not only iOS and Android, but also multiple Windows 10 platforms from a single app.

This is your chance to try out the latest-and-greatest in Xamarin.Forms. To help ensure that the next release of Xamarin.Forms is functional, stable, and performant, please let us know about any issues you encounter with the new Xamarin.Forms for UWP preview by filing a bug.

Getting Started

Download and extract the attached zip package that contains the preview NuGet packages. You will have to manually add the folder where the files were extracted to Visual Studio 2015’s NuGet package feed list.

Once you have that setup, you will want to:

  • Add a new Blank App (Universal Windows) project to your Xamarin.Forms solutions

  • Ensure the new project is configured to build and deploy in the configuration manager

  • Add the Xamarin.Forms nuget packages to the newly created project
  • Update Xamarin.Forms NuGets in the other projects, and
  • Configure the application by making the following changes to your UWP project code

Update App.xaml.cs

In OnLaunched under:

rootFrame.NavigationFailed += OnNavigationFailed;

Add:

Xamarin.Forms.Forms.Init (e);

Update MainPage.xaml

Remove all contents from page.

Add new xmlns of:

   xmlns:forms="using:Xamarin.Forms.Platform.WinRT"

Update root to:

<forms:WindowsPage
  ...>
</forms:WindowsPage>

Update MainPage.xaml.cs

    public sealed partial class MainPage
    {
        public MainPage()
        {
            InitializeComponent();
            LoadApplication (new YOUR_NAMESPACE.App());
        }
    }

Reference Your PCL/Shared Project

Don’t forget to add your reference to your portable class library or shared project where your Xamarin.Forms logic resides.

Known Issues
  • The look of some views/pages is not yet finalized.

  • There are a couple known crashers around navigation.

  • Text alignment may not be perfect in some titles.
  • Some things still use the older UAP naming. These will change to UWP.

We can’t wait to get your feedback! :)

Viewing all 91519 articles
Browse latest View live