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

Xamarin.UITest - Repl is not working

$
0
0

Hi all,
I am trying to run : app.Repl(); in my Xamarin.UITest but it is not working. Console window is opened, but error is thrown, saying that there are illegal characters in sdk path.
But Sdk path is correct and everything (apart of Repl) is working fine. In console it seems like there is one more quote at the end of the path, but I have no idea where it is coming from.
I tried to search for the error, and seems like it was not really solved. I tried to upgrade/downgrade my NUnit, Xamarin.UITest from Nuget packages, but I still got same error.

Any suggestions?

Thanks


Wrapping horizontal collection view

$
0
0

Hi to all, in my Xamarin Forms application i want to create something like this:

It gonna be bindable layout, but i can't understand what i have to use?
Can i wrap horizontal CollectionView or does it real with the FlexLayout?

Could not see the event details in firebase analytics

$
0
0
I have implemented firebase analytics to the track the events in my XamarinForms for project. In that I am facing problem in getting the event details. Following are my problem
1. I am able see event details for only recent 30 mins.
2. I am not able to group the event details.

Please help to achieve those two

display data from table to listview as required in many ways

$
0
0

Greeting everyone
i'm newbie in xamrin.forms and i'm doing some training so i'v created app for Stocktaking and here my table

class StocktakingTB
    {
        public string NameST { get; set; }
        public string NumberST { get; set; }
        public string BarcodeST { get; set; }

        public override string ToString()
        {
            return this.NumberST ;
        }

    } 

and here my listview it's show like this

and here my code

public Stocktaking()
        {
            this.Title = "Stocktaking";

            var db = new SQLiteConnection(_dbPath);

            StackLayout stackLayout = new StackLayout();

            _listViewStocking = new ListView();
            try
            {
                _listViewStocking.ItemsSource = db.Table<StocktakingTB>().OrderBy(x => x.NameST).ToList();
            }
            catch
            {

            }
            stackLayout.Children.Add(_listViewStocking);

            Content = stackLayout;
        }

so how can i display my listview in different way and be like this for example (accumulation the quantities)

and in the same time how can i create multiple different view of that table when i need because i'm planning to create different view for different screen for example some times need i add some fields like Barcode or Number?

[App Store Connect] ITMS-90338:& ITMS-90809

$
0
0

Hi Guys,

All code works well on app center, but when I deployed into App Store Connect, i got this feedback:

ITMS-90338: Non-public API usage The app references non-public selectors in My Project: applicationWillTerminate, ddSetLogLevel:, localTarget, newSocketQueueForConnectionFromAddress:onSocket:, setOrientation:animated:, socket:didConnectToHost:port:, socket:didReadPartialDataOfLength:tag:, socket:didReceiveTrust:completionHandler:, socket:didWritePartialDataOfLength:tag:, socket:shouldTimeoutReadWithTag:elapsed:bytesDone:, socket:shouldTimeoutWriteWithTag:elapsed:bytesDone:, socketDidCloseReadStream:, socketDidSecure:, terminateWithSuccess, webSocket:didReceiveMessage:, webSocketDidOpen:. If method names in your source code match the private Apple APIs listed above, altering your method names will help prevent this app from being flagged in future submissions. In addition, note that one or more of the above APIs may be located in a static library that was included with your app. If so, they must be removed.

PS: I was using Xamarin forms 4.5 pre release 4, adding mtouch argument: --linksdkonly but no luck

ITMS-90809: Deprecated API Usage - Apple will stop accepting submissions of apps that use UIWebView APIs .

PS: I was using Xamarin forms 4.5 pre release 4, adding mtouch argument: --linksdkonly --optimize=experimental-xforms-product-type but no luck

Here is my other info:
=== Visual Studio Community 2019 for Mac ===

Version 8.4.6 (build 36)
Installation UUID: b595cac1-d4ec-4401-bc08-4d169500d218
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 5.16.1.25 (issue-7441-d16-3-vsmac / 881172e73)

Package version: 606000155

=== Mono Framework MDK ===

Runtime:
Mono 6.6.0.155 (2019-08/296a9afdb24) (64-bit)
Package version: 606000155

=== Apple Developer Tools ===

Xcode 11.3.1 (15715)
Build 11C504

=== Xamarin.iOS ===

Version: 13.10.0.17 (Visual Studio Community)
Hash: 5f802ef53
Branch: xcode11.3
Build date: 2020-01-07 11:53:06-0500

=== Xamarin Designer ===

Version: 16.4.0.479
Hash: 074544417
Branch: remotes/origin/d16-4
Build date: 2020-01-22 22:50:22 UTC

=== Xamarin Inspector ===

Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 804060036
Git revision: 42d1ca78a76fba0d18b600f3bc001625088759a3
Build date: 2020-02-13 22:45:04+00
Build branch: release-8.4
Xamarin extensions: 42d1ca78a76fba0d18b600f3bc001625088759a3

=== Operating System ===

Mac OS X 10.15.2
Darwin 19.2.0 Darwin Kernel Version 19.2.0
Sat Nov 9 03:47:04 PST 2019
root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64

Can any one help to resolve this problem?

ListView: Binding Commands using ItemTemplateSelector

$
0
0

It's my curse. To demand too much and know too little...

For my ListView I use an ItemTemplateSelector class to decide which ItemTemplate/ViewCell to use. The ViewCells are located in separate files.

How can I bind a Button in my ItemTemplate/ViewCell to a Command in my MainViewModel ?
When it is a regular ListViewItem I can do it like this:

<Button Text="Test" Command="{Binding BindingContext.TestCommand, Source={x:Reference viewModel}}"/>

Is there any chance to get to the Parent Binding.Context within my ItemTemplate, best with MVVM ?

Reference broken

$
0
0

So becouse I am building an app for Venezuela, I ha to lower the Api on Android, but when I did that all the references broke

Any idea for Sharing text or url Post on Linkedin using Linkedin API?

$
0
0

I am working on to post/share on Linkedin from Xamarin mobile app. I have got the access token using OAuth2Authenticator and on Completed i have to send the share request on Linkedin but unable to found any workaround on this. Has anyone done this or any idea on sharing to Linkedin from mobile app? Please help.

  var lDAuth = new OAuth2Authenticator(
        clientId: "XXXXXXXXX",
        clientSecret: "XXXXXXXXXXXXX",
        scope: "w_member_social", /*r_liteprofile r_emailaddress w_member_social */
        authorizeUrl: new Uri("https://www.linkedin.com/uas/oauth2/authorization"),
        accessTokenUrl: new Uri("https://www.linkedin.com/uas/oauth2/accessToken"),
         redirectUrl: new Uri("http://www.google.co.in/")
        );
            lDAuth.AllowCancel = true;
            // If authorization succeeds or is canceled, .Completed will be fired.
             lDAuth.Completed += async (s, eventArgs) =>
            {
        // implementation for share on linkedin
    }

thank you.


How to add line breaks in a label in Xamarin Forms using XAML

$
0
0

I am trying to add line breaks to a label in Xamarin Forms using XAML, but it doesn't seem to work. This is the code I have right now that doesn't work:

<Label Text="All my text goes here etc\r\nawljfal alwef law fawlef lwemfalwfem" TextColor="White" WidthRequest="100" />

The '\r\n' actually outputs in the label text.

Over the air(OTA) device firmware update(DFU) for Nordic devices

$
0
0

Hi All,

I found a NuGet 'xamarin.nordic.dfu.android' which says "Enable over the air(OTA) device firmware update(DFU) for Nordic devices using Android and Bluetooth Low Energy(BLE)" which is exactly my requirement. I am trying to do DFU for a n52 device from xamarin.forms application.

But I am not finding any documentation on how this can be used /done. Anybody has used this library or any reference for this is much appreciated.

Thanks in advance,

Hide/show NavigationBar without moving the ContentPage up/down

$
0
0

Hi everyone!

I am using GestureRecognition (a tap on the screen) to make the NavigationBar appear and disappear.

The problem I found is that when I do this, the whole ContentPage moves down/up as the NavigationBar appears/disappears, but I need it to stay exactly on the same scroll position.

I thought about auto-scrolling up/down the exact height of the NavigationBar, but maybe there is another way?
The problem with this is that I need to get the NavigationBar height, and apparently is not that easy.

I found this post: https://forums.xamarin.com/discussion/comment/415161#Comment_415161
But I don't know how to access the variable.

Am I solving it the right way? If it is the right way, can someone help me to understand how to get the var Height from another class?

Thanks a lot!!

Instances of ViewModels and Changing Properties from other classes?

$
0
0

I have a button with a command, it's BindingContext is set to RedViewModel

    <ContentView.BindingContext>
        <vm:RedViewModel />
      </ContentView.BindingContext>

    <Button x:Name="BlueButton"
                Grid.Row="0"
                Command="{Binding NavigateToBlueVCommand}"
                Text="Blue" />

This is bound to a command property in the RedViewModel;

    public ICommand NavigateToBlueVCommand { private set; get; }

    public RedViewModel() 
            {
                NavigateToBlueVCommand = new Command(execute: () =>
                {
                    NavigationClass.ChangeView(new BlueView());

                });
        }

The NavigationClass takes the passed view and adds it to a stack and sets the MainPageViewModel's property to the new Vaule (The setter calls the OnPropertyChanged() method )

    private static List<ContentView> _navigationStack = new List<ContentView>();
    private static MainPageViewModel _mpvm = new MainPageViewModel();


            public static void ChangeView(ContentView nuView)
            {
                if (nuView == null) throw new NullReferenceException();
                try
                {
                    _navigationStack.Add(nuView);
                    _mpvm.DisplayedView = nuView;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }

            }

I have debugged it and can follow all the setps through and the value of displayedview property on _mpvm exactly matches blueView and the OnPropertyChanged(), identifies the correct property that called it, but the UI does not change.

if however I change the command execute code in the ViewModel, so the value is assigned in the ViewModel it works fine;

        NavigateToBlueVCommand = new Command(execute: () =>
        {
          DisplayedView = new BlueView()  ;
        });

Therefore, my theory is, the problem is in the fact that I create a new instance of the MainPageViewModel, in the Navigation Class, instead of using the instance created when the Mainpage BindingContext was assigned ? (or more likely this is just crazy, way of the mark thinking).

dyld: Library not loaded: @rpath/GoogleToolboxForMac.framework/GoogleToolboxForMac ERROR

$
0
0

Hello
I just tried to distribute xamarin from ios i created one certificate for distribution from apple dev center and again the app stop working on Debug mode and also distribution moode
i am getting this error

Application 'com.companyname.Sshsh' terminated.
dyld: Library not loaded: @rpath/GoogleToolboxForMac.framework/GoogleToolboxForMac
  Referenced from: /var/containers/Bundle/Application/A715F058-8AC6-4E52-94F8-F24EDFD1D959/Sshsh.iOS.app/Sshsh.iOS
  Reason: no suitable image found.  Did find:
    /private/var/containers/Bundle/Application/A715F058-8AC6-4E52-94F8-F24EDFD1D959/Sshsh.iOS.app/Frameworks/GoogleToolboxForMac.framework/GoogleToolboxForMac: code signature in (/private/var/containers/Bundle/Application/A715F058-8AC6-4E52-94F8-F24EDFD1D959/Sshsh.iOS.app/Frameworks/GoogleToolboxForMac.framework/GoogleToolboxForMac) not valid for use in process using Library Validation: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)
Xamarin.Hosting: Launched com.companyname.Sshsh with PID: 4337

Could anyone help me
Thank you

how to upload image to the server using api in xamarin forms?

Xamarin Forms: Userdialogs showloading is not working in ios

$
0
0

I am using Acr.UserDialogs Nuget Package for showing the loading progress in my projects. It is working fine on android and windows, but not showing on IOS. I am using the following line of code for the progress dialog:

UserDialogs.Instance.ShowLoading("");

Version Details:

Acr.UserDialogs: 7.0.26
Xamarin forms: 4.6.0.726

Not added any initialization code on ios because it is optional.

For post services, the ShowLoading is working. But for the get services, there is no loading showing on the UI. I will add a sample project for the reference ASAP.


How to the CSS for each platform in the App.xaml?

$
0
0

I've tried and tried but can't get this to work. Maybe it's not possible. I would like to load a css file per platform. Here's what I've tried.

<?xml version="1.0" encoding="utf-8" ?>
<Application
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="eTabber.App">
    <Application.Resources>
        <StyleSheet Source="/css/Main.css" />
        <StyleSheet Source="{OnPlatform iOS=/css/iOS.css, Android=/css/Android.css}" />
    </Application.Resources>
</Application>

ERROR: Source is not a String Literal

and this:

<?xml version="1.0" encoding="utf-8" ?>
<Application
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="eTabber.App">
    <Application.Resources>
        <StyleSheet Source="/css/Main.css" />
        <StyleSheet Source="/css/Dummy.css" >
            <StyleSheetExtension.Source>
                <OnPlatform x:TypeArguments="x:Uri">
                    <On Platform="Android">/css/Android.css</On>
                    <On Platform="iOS">/css/iOS.css</On>
                </OnPlatform>
            </StyleSheetExtension.Source>
        </StyleSheet>
    </Application.Resources>
</Application>

This compiles but does nothing at all (Ok, it does load the dummy.css). If I leave out the 'Dummy.css' it complains it needs a 'Source'.

I also tried loading it in code behind. That works but then 'Hot XAML reloading' is not working.

B.t.w: compilation of this stuff is just instable. I had to delete 'bin' and 'obj' on several occasions and also had to restart VS2019.

C# Xamarin Forms MessagingCenter not updating Item passed

$
0
0

I am using MessagingCenter to passe objects throu my pages, from my LoginPage to my MainPage. Even tho the object is updated, when using it to my mainpage, the object seems to be null.

public User sUser { get; set; }
public MainPage()
{
    InitializeComponent();

    MessagingCenter.Subscribe<LoginPage, User>(this, "currentUserMainPage", (obj, item) =>
    {
        sUser = item;
        Debug.WriteLine("User updated from mainPage ");
    });

    MasterBehavior = MasterBehavior.Popover;

    MenuPages.Add((int)MenuItemType.Home, (NavigationPage)Detail);
}`

When I check for the object before changing pages, even tho it is not null anymore, it returns me null.

public async Task NavigateFromMenu(int id)
{
    if (!MenuPages.ContainsKey(id))
    {
        switch (id)
        {
            case (int)MenuItemType.Profile:
                if(sUser == null)
                {
                    MenuPages.Add(id, new NavigationPage(new LoginPage(sUser)));
                }
                else
                {
                    MenuPages.Add(id, new NavigationPage(new ProfilePage(sUser)));
                }
                break;
        }
    }
 }

button click on xamarin forms map infowindow's button

$
0
0

Hi,

I am showing infowindow on click of map pin. In infowindow I am showing text, spinner and button.

void OnInfoWindowClick(object sender, GoogleMap.InfoWindowClickEventArgs e)
{
var customPin = GetCustomPin(e.Marker);
if (customPin == null)
{
throw new Exception("Custom pin not found");
}

        if(customPin.Name != null)
        {
            var address = Android.Net.Uri.Parse("https://google.com");
            var intent = new Intent(Intent.ActionView, address);
            intent.AddFlags(ActivityFlags.NewTask);
            Android.App.Application.Context.StartActivity(intent);
        }
    }

when I am clicking on infowindow or any control like spinner or button, it is redirecting me on google.com which I have written in my code.

I do not have any idea how can I handle button click event and spinner selection change here.

Can anyone suggest me the way to handle it?

How to bind collection view selected items into a new listview using MVVM?

$
0
0

I have the following observableCollection:
Main View Model:

MainViewModel : INotifyProperyChanged
 public MainViewModel()
{
Accessories = new ObservableCollection<string>();
            Accessories.Add("Cast");
              Accessories.Add("Neck Ring");
             Accessories.Add("Shoulder Wedges");
            Accessories.Add("Grip Rings");
            Accessories.Add("Head Rest");
            Accessories.Add("Knee Roll");
            Accessories.Add("Elbow Sling");
             Accessories.Add("Thermoplastic Mask");
            Accessories.Add("Vacuum Lock Bags");
            Accessories.Add("Breast Board");
}

 public ObservableCollection<string> selectedAccessories = new ObservableCollection<string>();
        public ObservableCollection<string> SelectedAccessories
        {
            get => selectedAccessories;
            set
            {
                if (selectedAccessories == value)
                    return;
                else
                {
                    selectedAccessories = value;
                    OnPropertyChanged(nameof(SelectedAccessories));

                }
            }
public event PropertyChangedEventHandler PropertyChanged;
         public void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

Then on the XAML Side:

    <CollectionView ItemsSource="{Binding Accessories}" SelectionMode="Multiple" SelectedItems="{Binding SelectedAccessories}" />

    <Label x:Name="label1" Text="{Binding SelectedAccessories}"  />

    <ListView x:Name="list1" ItemsSource="{Binding SelectedAccessories}"  />

I would like to display in either a label or listview (both work). Now, Selected Accessories is an observable collection that would need to be the ItemsSource for the new list.

I also tried a different PropertyChanged method and it still doesn't work:

public event PropertyChangedEventHandler PropertyChanged;
        publicvoid OnPropertyChanged2(ObservableCollection<string> selectedAccessories)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(selectedAccessories.ToString()));
        }

The same structure work for other data types but I can't make it work for ObservableCollections. Do I need to create a method to retrieve the strings of the selected items? How can I access the selectedItems?

How to handle UnhandledException in Xamarin Forms?

$
0
0

I try my best to catch exceptions throughout my app, but sometimes there are still unhandled exceptions.
I've tried to add this code in the Xamarin Forms App.xaml.cs, then in Android MainActivity.OnCreate and iOS AppDelegate.FinishedLaunching to see if it made any difference:

AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
{
    var exception = (Exception)e.ExceptionObject;

    // Try do log the exception, or show an alert etc.
    AppCenter.Crashes.TrackError(exception);
}

The behavior is always the same: I can print the exception to the output window, but even a simple call to AppCenter.Crashes.TrackError(exception); will not execute. Somehow it crashes again on that line (or anything i try to do, like calling NLog, or writing to a file, or to the local database).

So, is there any way to make this work and catch unhandled exceptions in Xamarin Forms?

Thanks

Viewing all 79144 articles
Browse latest View live


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