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

NSNotificationService to the PCL

$
0
0

Hi! I am very new to Xamarin so I would like you to have that in mind =)
I am building an app in Xamarin Forms that will have to connect to bluetooth devices. I am working on a "Devices-in-your-vicinity-to-connect-with-list"-view at the moment.

The CBCentralManager in the iOS part of the app, I am using to scan for devices works properly, I think, and it posts the devices via NSNotificationCenter. The problem I'm having is to figure out how I transfer the device-data to my listView in the PCL and have it update when a new device is detected. Usually I transfer data between the platforms specific parts to the PCL via the DependencyService, but I don't know how to create the interface and class so that it works with NSNotification and the event handling.
There are some solutions that I can come up with but none of them are neat and clean.

Does anyone know if there is a good way of doing this with the NSNotificationCenter or if there is something better?


Powerpoint viewer in Xamarin.Forms

$
0
0

Hello, I am interested in a Powerpoint viewer for Xamarin.Forms, Does Xamarin support that? If so, could you please recommend a library or NuGet that allows me to view Powerpoint presentations in Xamarin.Forms?

Adding Filter on image

$
0
0

i need to add layer on image and change the color of this layer as per the value on slider. Any suggestion would be welcomed. Thanks in advance.

Filter a list view by keyword...

$
0
0

I have created a simple list with a keyword textentry field that filters the list based on the keyword. I can filter the list but unsure how i unfilter the list! ie When i filter the collection based on the keyword..i can't seem to refilter the original list as the original collection is filtered.

using etech.zspotter.Models;
using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Navigation;
using Prism.Services;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace etech.zspotter.ViewModels
{
public class ClientsViewModel : BindableBase
{
#region Fields

    public ObservableCollection<ListViewContactsInfo> contactsInfo;

    #endregion

    #region Constructor


    INavigationService _navigationService;
    public DelegateCommand<string> TextChangedCommand { get; set; }
    public DelegateCommand<object> SelectCommand { get; set; }
    public ClientsViewModel(INavigationService navigationService, IPageDialogService ipageserve, IEventAggregator ea)
    {
        _navigationService = navigationService;
        TextChangedCommand = new DelegateCommand<string>(TextChangedCommandHandler);
        SelectCommand = new DelegateCommand<object>(SelectCommandHandler);
        GenerateSource(100);
    }

    private void TextChangedCommandHandler(string obj)
    {
        keyword = obj;
    }

    private async void SelectCommandHandler(object obj)
    {
        await _navigationService.NavigateAsync($"Sites?site=33");
    }

    #endregion

    #region Properties

    string _keyword;
    public string keyword
    {
        get
        {
            return _keyword;
        }
        set
        {
            _keyword = value;
            if (string.IsNullOrEmpty(_keyword))
            {
                ContactsInfo.Clear();
                foreach (var item in contactsInfo)
                {
                    ContactsInfo.Add(item);
                }
            }
            else
            {
                var ContactsInfo = new ObservableCollection<ListViewContactsInfo>(this.contactsInfo.Where(x => x.ContactName.Contains(keyword.ToString())));
                ContactsInfo.Clear();
                foreach (var item in ContactsInfo)
                {
                    ContactsInfo.Add(item);
                }

            }
        }
    }

    public ObservableCollection<ListViewContactsInfo> ContactsInfo
    {
        get
        {
            return this.contactsInfo;
        }
        set { SetProperty(ref this.contactsInfo, value); }
    }

    #endregion

    #region ItemSource

    public void GenerateSource(int count)
    {
        ListViewContactsInfoRepository contactRepository = new ListViewContactsInfoRepository();
        contactsInfo = contactRepository.GetContactDetails(count);
    }

    #endregion



}

}

How to use FlexLayout in a MVVM framework?

$
0
0

I can fill a FlexLayout dynamically with labels from a collection in the code behind like that (labels are wrapped to several rows):

       foreach (WordItem item in _items)
        {
            Label label = new Label
            {
                Text = item.Name,
                Margin = new Thickness(2, 0, 2, 0),
                FontSize = 16,
                TextColor = Color.Black,
                BackgroundColor = Color.AliceBlue
            };

            flex1.Children.Add(label);
        }

But I can't imagine how to do it in a MVVM application (I'm using Prism/DryIoc). What would be the source property for binding dynamically several labels to the FlexLayout?
Every answer is appreciated!
Marc

Unable to select items in a ListView only on Android

$
0
0

I have an XF app that's been on the store for a while now. After my last update for iOS (to fix some bugs introduced in the update before that), I went to get Android caught back up (never released the second to last update because of said bugs). For some reason though, I'm no longer able to select items in the list view on the main page displayed when the app launches.

I can interact with everything else on the screen (menu, a + button in the top right, several button at the top of the screen, a search bar), but nothing happens when I tap on any items in the list view. If I hit the plus button, I can add items to the list view correctly, and when I add a new item it opens it into a new view as it's supposed to (and what would otherwise happen when selecting an item), and I can select items in all the other subviews in the app, but for some reason, not in that first one. Putting breakpoints in the getter/setter methods for the view model property the SelectedItem is set to are never hit. The same view works fine on iOS.

xaml for the view in question: https://github.com/timrisi/AuroraSquadBuilder/blob/master/SquadBuilder/View/MainView.xaml

Let's talk performance

$
0
0

As we continue to release performance focused features and fixes, and build processes around performance, I want to have a thread dedicated to those items.

Our public roadmap itemizes the feature work we are doing and planning to do, and items related to performance are tagged. In addition to that, we are building into our CI processes ways to measure and compare performance metrics. The goal is that with specific commits and builds we can get visibility to any impact on speed and memory usage.

One of the initiatives I'm spearheading is to populate a solution with UIs that are representative of your applications. To that end, I'm asking you to consider sharing those layouts with us. Perhaps the best way to gather them would be to open a repository and have you submit pull requests. I'll get working on that next and post details here.

Fast Renderers for Android are now merged and in nightly and will be our next pre-release. I hope some of you will take some time to test them out and report back here with your findings.

Forms2Native example, iOS controls not rendering

$
0
0

Hi!

I recently downloaded the Forms2Native example published by Xamarin here, as well as created my own sandbox projects trying to do the same thing, but the iOS controls will not render on the simulator. Android works fine.

Is there something I am missing?

Thanks in advance for any help!


The type or namespace name 'System' could not be found

$
0
0

When I try to create a new Xamarin Forms app, nothing works. No imports can be found. Almost every line in the autogenerated code has a "not found" error.

Using Visual Studio 2017 15.5.6 on Windows 10.

How to implement localization in the latest 2017 VS without using PCL?

$
0
0

Hello

In previous projects I used the resx/PCL approach to implement localization in my Xamarin.forms solutions. As of the update to VS, this has been deemed deprecated and the information I find instruct me to "use the .NET standard".

When trying to implement a resx language file, the strongly typed connection is no longer available and the ResXFileCodeGenerator tool for converting resx to designer.cs "does not exist in a non .NET environment".

VS still allows me to add a PCL project to my Xamarin.forms, but since it has officially been depricated, I do not want to use that.

The article at Xamarin describing how to do it (https://developer.xamarin.com/guides/xamarin-forms/advanced/localization/), has yet to be updated to use .NET standard, where the resx file is automatically converted into a designer.cs file, that used to enable the strongly typed use of strings.

Are there anyone out there that could help me create a way to use localization in the latest VS 2017 (for Mac) without using a PCL nor individual implementation of localization in separate platforms (Andorid/iOS)?

Collecting User Feedback within application

$
0
0

What would be the best approach to tackle this issue if user is given a location within the app to provide feedback on. Should I approach this using a form post approach or are there tools that I could use to integrate into my app that would essentially handle this?

Is there any way to copy the text of Label in Xamarin.Forms

$
0
0

We are working on Xamarin cross-platform application, and we are using a custom Grid with the help of ListView and Label. And our customers want to copy the text of Label by using Ctrl + C or using Copy on Mouse Right click.

Is there any way to copy the text of Label.

The webviewNavigating method does not fire for webview in uwp

$
0
0

On iOS and Android my webview will call the webviewNavigating method but when I run the app in uwp it does not call it. Does anyone have any idea why or what I can do about it? I use that method to catch certain urls' and open them in external browser.

LaunchScreen.storyboard appears black

$
0
0

Hi all!

Im using Xamarin Forms in Beta and experiencing an issue in IOS. Whenever my app launches on my Device or Emulator all i see is a black screen as the Splash Screen.. this started happening a week ago in my project and even if i create a new project and does nothing but deploy it, i get the same black screen. Im building an Universal App that runs on both iPhone and iPad and have a LaunchScreen.Storyboard in my Resources folder in the IOS project.. (Its created default, and i can see it in IOS project -> Properties -> iOS Application -> Launch Storyboard it says "LaunchScreen"..

Anybody experienced the same, or have any ideas what to do??

Thanks in advance..

Forms 3.0 and Live Player

$
0
0

I can deploy app via USB, but cannot use Live Player for the new Forms 3.0. I receive this error when trying thru Live Player... Type FlexLayout not found in http: //xamarin.com /schemas /2014 /forms. Anything else required?


How to improve Listview performance?

$
0
0

I have used cachestragegy but still not effective, is there any other way to improve performance for listview? Sorry my bad english.
Thank in advance.

Bug Report: Xamarin Forms NuGet conflict

$
0
0

I've just reinstalled Visual Studio to confirm this bug, which took several hours.

Create a new Android app (single page).

In Package Manager Console, type

install-package Xamarin.Forms

This generates the following error:

install-package : NU1107: Version conflict detected for Xamarin.Android.Support.Compat. Reference the package directly from the 
project to resolve this issue. 
 App5 -> Xamarin.Android.Support.Design 27.0.2 -> Xamarin.Android.Support.Compat (= 27.0.2) 
 App5 -> Xamarin.Forms 3.0.0.482510 -> Xamarin.Android.Support.v4 25.4.0.2 -> Xamarin.Android.Support.Compat (= 25.4.0.2).
At line:1 char:1
+ install-package Xamarin.Forms
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

install-package : Package restore failed. Rolling back package changes for 'App5'.
At line:1 char:1
+ install-package Xamarin.Forms
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

I am completely blocked by this.

Datepicker, serious problems

$
0
0

Hi all together,
i have serious Problems with Datepicker.

ProjectWorkTimeDetailViewModel.cs
public class ProjectWorkTimeDetailViewModel
{
more code..................
public override void OnNavigatedTo(NavigationParameters parameters)
{
base.OnNavigatedTo(parameters);
if (parameters.ContainsKey("PWT"))
{
var projectWorkTime = (ProjectWorkTime)parameters["PWT"];
CurrentWorkTime = new ProjectWorkTimeEdit(projectWorkTime);
CurrentWorkTime.PropertyChanged += OnPropertyChange;
}
}

private void OnPropertyChange(object sender, PropertyChangedEventArgs e)
    {
        if (!Title.EndsWith("*"))
        {
            Title = Title + " *";
        }
        _canSave = true;
        SaveCommand.RaiseCanExecuteChanged();
    }

}

ProjectWorkTimeDetail.xaml

                <ViewCell>
                    <StackLayout Orientation="Horizontal"   Padding="13,0">
                        <Label Text="Arbeitstag:  " VerticalOptions="Center"></Label>

                        <DatePicker Format="dd MMM yyyy"
                                Date="{Binding CurrentWorkTime.WorkDay,Mode=TwoWay}"
                                HorizontalOptions="FillAndExpand"></DatePicker>
                    </StackLayout>
                </ViewCell>

ProjectWorkTimeEdit.cs
public class ProjectWorkTimeEdit : BindableBase
{
ProjectWorkTime _entity;

    public ProjectWorkTimeEdit (ProjectWorkTime entity)
    {
        if (entity == null)
        {
            throw new ArgumentNullException(nameof(entity));
        }

        _entity = entity;
       _workDay = entity.WorkDay;
        _job = _entity.Job;
        _workTime = _entity.WorkTime;
    }

    DateTime _workDay;
    public DateTime WorkDay
    {
        get => _workDay;
        set => SetProperty(ref _workDay,value);
    }

........... more code
}

As you can see i'm initializing 'ProjectWorkTimeEdit.cs' and set values in the Constructor. After that, i add the 'OnPropertyChanged' EventHandler.

Directly after this Line:
CurrentWorkTime.PropertyChanged += OnPropertyChange;

I have a Event fired from

 public DateTime WorkDay
{
     set => SetProperty(ref _workDay,value);
}

here without doing anything

I'm shure that this problem has something todo with the Datepicker because if i commented out the Datepicker all works as expected.

Any idea???

Thanks in advance
Peter

Localization not working in culture fr in XamarinForms PCL

$
0
0

I have tried to localize the Xamarin Forms application from PCL project , resource file get localized for culture (en-US,ta,de,ja) but French culture (fr or fr-FR) not localizing , checked in XamrinForms.UWP and XamarinForms.Android.

Please share your suggestion.

Flex Layout Entry Not Centering Text

$
0
0

I have an entry box inside of a flex layout. I want the entry to display across the whole screen with some margin and still have the text/placeholder text centered. I currently cannot get the entry to have it's text centered nor apply a margin to the left and right sides.

What I want:

What I'm getting:

Code Inside a content page and with relevant parts:

<FlexLayout Direction="Column"
                    AlignContent="Center"
                    AlignItems="Center"
                    JustifyContent="SpaceEvenly"
                    HorizontalOptions="FillAndExpand"
                    VerticalOptions="FillAndExpand">
`
`
            <Image Source="Banner.png"
                   Aspect="AspectFit"
                   Scale="0.85"/>

            <StackLayout x:Name="ControlsHolder_StackLayout" 
                         Orientation="Vertical"
                         HorizontalOptions="FillAndExpand"
                         VerticalOptions="FillAndExpand"
                         Spacing="20">

                <Label x:Name="WelcomeMessage_Label"
                       Text="Welcome to the General Aire contractor App.
                             Please enter your general Aire contractor number to begin."
                       HorizontalTextAlignment="Center"
                       HorizontalOptions="CenterAndExpand"
                       TextColor="White"
                       FontSize="Small" />

                <Entry x:Name="ContractorNumber_Entry"
                       HorizontalTextAlignment="Center" 
                       Placeholder="Enter Contractor Number"
                       PlaceholderColor="{StaticResource GFI_Gray}"
                       TextColor="White"
                       FlexLayout.AlignSelf="Center"
                       HorizontalOptions="FillAndExpand">
                </Entry>
Viewing all 91519 articles
Browse latest View live


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