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

How number of text field will be added depending on number of button click

$
0
0

If i press once Button means one text field will be added.If i press twice means again new text field will be added.How can i do it any suggestion please?


Nested ListView in Xamarin.Forms (ListView inside another ListView)

$
0
0

I have created a nested ListView in Xamarin.
But unfortunately, the binding works only with the Parent ListView and NOT with the Child List - sub ListView.

I tried to verify if there is any error with my Binding, and my binding works well with the sub List, if i make it as parent.
Any help on this binding, or approach for nested ListView bindings in Xamarin with samples would be much helpful.

3D Touch in forms (including peek/pop!)

How to open default contacts app in xamrin forms?

$
0
0

How to open default contacts app in xamrin forms?

Issue creating APK in VS 2017

$
0
0

Hi,
My Xamarin.Forms app works in debug mode, but if I build in release mode and I try to create an APK from VS 2017, it doesn't work.
The build process succeeded but the APK is not yet created.
My Xamarin.Forms version is 3.4.0.1008975 and my VS is up to date.

Target Android version is 9.0.

Here above the application logs:

Xamarin.VisualStudio.Publishing.ArchiveManager|Error|0|System.NotSupportedException: This type of CollectionView does not support changes to its SourceCollection from a thread different from the Dispatcher thread.
at System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
at System.Collections.ObjectModel.ObservableCollection1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at Microsoft.VisualStudio.PlatformUI.HierarchyItem.HierarchyItemCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection1.InsertItem(Int32 index, T item)
at System.Collections.ObjectModel.Collection1.Add(T item) at Microsoft.VisualStudio.PlatformUI.HierarchyItem.AppendChildren(IVsHierarchy hierarchy, UInt32 itemID, List1 appendedChildren)
at Microsoft.VisualStudio.PlatformUI.HierarchyItem.FillChildren()
at Microsoft.VisualStudio.PlatformUI.HierarchyItem.get_InternalChildren()
at Microsoft.VisualStudio.PlatformUI.HierarchyItem.get_Children()
at Clide.SolutionExplorerNode.get_Nodes() in E:\A_work\184\s\src\Clide\Solution\SolutionExplorerNode.cs:line 166
at Clide.ITreeNodeExtensions.<>c.b__1_0(ISolutionExplorerNode x) in E:\A_work\184\s\src\Clide.Interfaces\Extensions\ITreeNodeExtensions.cs:line 33
at Traverser.d__21.MoveNext() in E:\A\_work\184\s\src\Clide.Interfaces\Extensions\Traverser.cs:line 70 at System.Linq.Enumerable.<OfTypeIterator>d__951.MoveNext()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Clide.AndroidClideExtensions.GetAndroidResources(IProjectNode projectNode) in E:\A_work\293\s\src\Core\VisualStudio.Android\ProjectSystem\Extensions.cs:line 128
at Xamarin.VisualStudio.Android.Publishing.AndroidArchiveToolsService.CreateParameters(IProjectNode project) in E:\A_work\293\s\src\Core\VisualStudio.Android\Services\Publishing\Archival\AndroidArchiveToolsService.cs:line 186
at Xamarin.VisualStudio.Android.Publishing.AndroidArchiveToolsService.ArchiveAsync(IProjectNode project, IProgressReport progress, CancellationToken cancellationToken) in E:\A_work\293\s\src\Core\VisualStudio.Android\Services\Publishing\Archival\AndroidArchiveToolsService.cs:line 113
at Xamarin.VisualStudio.Publishing.ArchivableProjectBase.d__8.MoveNext() in E:\A_work\293\s\src\Core\VisualStudio.Publishing\Archival\ArchivableProjectBase.cs:line 30
--- End of stack trace from previous location where exception was thrown ---

Data from Api not binding to custom entry field properly

$
0
0

I have multiple fields in a section of my page such as amount, tax, Gross Total. I am getting data from api and binding the data from code behind (NOT using MVVM). Sometimes values are binding correct and sometimes incorrect values are binding to it. I am unable to understand exactly what is the problem. Values from api are always correct i have tested on postman.

Code -

XAML-

Code Behind-
Total.Text = result.Total.ToString();

Correct value of total is suppose - 8500/-
sometimes it is correct displayed as 8500/- but sometimes it displays 6500/-, sometimes 7500/-.

Can anybody suggest any solution.

Thank you.

Geting the value of a Picker in Xamarin Forms

$
0
0

How can i get the value of any Picker, is there any property like .Value or .selectedValue? or how can i achieve this in xamarin forms? or do i have to binding an object with BindingContext and get the index of the value and convert it to a string object?

How to Use Navigation Push ASync in Master Detail Page Menu

$
0
0

I want to make my xamarin forms app when the menu item is clicked instead change the master detail page it go to another page and shows navigation bar with back button in the top. but i got confused in how to change the on menu item selected, here is my onmenuitemSelected

private void OnMenuItemSelected(object sender, SelectedItemChangedEventArgs e)
{

        var item = (DrawerItem)e.SelectedItem;
        Type page = item.TargetType;

        //Navigation.PushAsync((Page)Activator.CreateInstance(page));
        //new NavigationPage((Page)Activator.CreateInstance(page));

        Detail = new NavigationPage((Page)Activator.CreateInstance(page));
       IsPresented = false;
    }

As you can see in the comment tag i already try to do Navigation.Push async and tried New NavigationPage only without Detail but when im click the menu item its do nothing, so what code should i write to do that.


Problem to load an Image

$
0
0

Hi all,
so this is my first day in Xamarin. I am was looking the answer but nothing helped me. So :
1. I right click on Drawable->add->existing item->image.png
2. In xaml I add
3. ... but no image appear and I donw know why

From C# WPF I used to add image via : Right click on my project->properties->Resources->[image] ->add existing file .. but none wirking

Can you help me?

How to stop vidio playing in WebView

$
0
0

Dear experts,

I work on a Xamarin.Forms app (UWP!). It has a Master-Details architecture. The Master page has a ListView, and each item in it opens a corresponding Detail page. The first Detail page has only a WebView that plays a YouTube video upon loading. The second Detail view has just a placeholder label for now. Where I switch from first Detail page to the second, the sound of the video from the first Detail page is still heard. And when I switch back to the first Detail page, the video loads again, and now I hear two voices. How can I stop the video upon switching to the second Detail page and resume when going back? If this is not possible, how can I just stop the video upon leaving its Detail page?

Here is some code:

In MainMDPage.xaml.cs:

`
private void ListView_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
var item = e.SelectedItem as MainMDPageMenuItem;
if (item == null)
return;

        var page = (Page)Activator.CreateInstance(item.TargetType);

        Detail = new NavigationPage(page);
        IsPresented = false;

        MasterPage.ListView.SelectedItem = null;

        PreviouslySelectedItem = item;
    }

`

In MainMDPageMaster.xaml.cs:

`
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainMDPageMaster : ContentPage
{
public ListView ListView;

    public MainMDPageMaster()
    {
        InitializeComponent();

        BindingContext = new MainMDPageMasterViewModel();
        ListView = MenuItemsListView;
    }

    class MainMDPageMasterViewModel : INotifyPropertyChanged
    {
        public ObservableCollection<MainMDPageMenuItem> MenuItems { get; set; }

        public MainMDPageMasterViewModel()
        {
            MenuItems = new ObservableCollection<MainMDPageMenuItem>(new[]
            {
                new MainMDPageMenuItem { Id = 0, Title = "Videos", TargetType = typeof(VideoPage), IconSource = @"Assets\film-strip.jpg" },
                new MainMDPageMenuItem { Id = 1, Title = "Products", TargetType = typeof(ProductsPage), IconSource = @"Assets\products.jpg" },
            });
        }

        #region INotifyPropertyChanged Implementation
        public event PropertyChangedEventHandler PropertyChanged;
        void OnPropertyChanged([CallerMemberName] string propertyName = "")
        {
            if (PropertyChanged == null)
                return;

            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
        #endregion
    }
}`

Thanks!

How to MessagingCenter.Subscribe to same message from multiple senders

$
0
0

I want to subscribe to a message that can be sent from multiple ViewModels. Is there a more elegant solution than subscribing individually for each ViewModel, like I do below?

MessagingCenter.Subscribe<Page1Model, bool>(this, "SomeMessage", MyMethod);
MessagingCenter.Subscribe<Page2Model, bool>(this, "SomeMessage", MyMethod);

Load Platform-specific Bitmap Icon

$
0
0

Hey there. I cant see an Icon. The Label say "Rendered size = 0 x 0". I dont know where my mistake is. For the purpose of an successful test Im currently running the iOS emulator. Here is the code:

public class PlatformBitmapsPageCode : ContentPage
    {
        string icon;

        public PlatformBitmapsPageCode()
        {

            switch (Device.RuntimePlatform)
            {
                case Device.iOS:
                    icon = "Icon40.png";
                    break;
                case Device.Android:
                    icon = "icon.png";
                    break;
            }

            Image image = new Image
            {
                Source = new FileImageSource
                {

                    File = icon
                   // File = "Icon-Small-40.png"
                },
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            Label label = new Label
            {
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                HorizontalOptions = LayoutOptions.Center,
            VerticalOptions = LayoutOptions.CenterAndExpand
        };

        image.SizeChanged += (sender, args) =>
        {
            label.Text = String.Format("Rendered size = {0} x {1}", image.Width, image.Height);
        };

        Content = new StackLayout
        {
            Children =
            {
                image,
                label

            }
        };
    }
}

So basically this code should load an Icon and give me the rendered Size of it. But the Icon does not load hence the rendered size is at 0x0.

In the tutorial I got this code from the iOS Icon name should be "Icon-Small-40.png" which should be stored in the Resources folder.
I noticed that this .png is not there. But there are a few Icons in Assets.xcassets/AppIcon.appiconset.
I copied Icon40.png from there into the Resources folder but it did not help.

What can I do to make it work?

StripeView in Xamarin Forms

$
0
0

I did a little research and it seems braintree and stripe are suitable for app payments.
braintree has no official xamarin bindings but there's a Stripe component by Xamarin for Android and iOS.
is it possible to use this component in Xamarin.Forms (and it's StripeView UI) ?

Native linking failed error in xamarin for GoogleSign

$
0
0

I am following this tutorial for GoogleSign in my project. https://www.pujolsluis.com/google-client-plugin-for-xamarin/ .Works fine in android. But getting Native linking failed errors while rebuild in ios.

Native linking error: clang: error: no such file or directory: '/Users/cybasetechnologies/Library/Caches/Xamarin/mtbs/builds/login2.iOS/0f92dcc98e9717a0d2643ed70077af70/obj/iPhone/Debug/mtouch-cache/FirebaseInstanceID'
Native linking error: clang: error: no such file or directory: '/Users/cybasetechnologies/Library/Caches/Xamarin/mtbs/builds/login2.iOS/0f92dcc98e9717a0d2643ed70077af70/obj/iPhone/Debug/mtouch-cache/FirebaseNanoPB'
Native linking failed. Please review the build log.
Native linking error: clang: error: no such file or directory: '/Users/cybasetechnologies/Library/Caches/Xamarin/mtbs/builds/login2.iOS/0f92dcc98e9717a0d2643ed70077af70/obj/iPhone/Debug/mtouch-cache/FirebaseCoreDiagnostics'
Native linking error: clang: error: no such file or directory: '/Users/cybasetechnologies/Library/Caches/Xamarin/mtbs/builds/login2.iOS/0f92dcc98e9717a0d2643ed70077af70/obj/iPhone/Debug/mtouch-cache/FirebaseAnalytics'
Native linking error: clang: error: no such file or directory: '/Users/cybasetechnologies/Library/Caches/Xamarin/mtbs/builds/login2.iOS/0f92dcc98e9717a0d2643ed70077af70/obj/iPhone/Debug/mtouch-cache/GoogleSignIn'
Native linking error: clang: error: no such file or directory: '/Users/cybasetechnologies/Library/Caches/Xamarin/mtbs/builds/login2.iOS/0f92dcc98e9717a0d2643ed70077af70/obj/iPhone/Debug/mtouch-cache/FirebaseCore'

Deleted bin and obj folders in both mac and visualstudio; clean and rebuid; still error persists.Please help..

Is it possible to have ItemSelected and LongPress events in same listview

$
0
0

Im wondering if it is possible to have a listview that reacts to Listview's ItemSelected event, but if i hold that view cell another event is being called. The way I tried, to make custom renderer for long press, but it overrides the ItemSelected, so only LongPress works.
Any suggestions?

Thank you!


How to fetch data from servers when app is not running?

$
0
0

This probably may be duplicate, but i kind of have specific need.

So, i need a way to fetch data from the server, when a user receive a Push Notification, while the app is not in running state.
i.e. User do receive a notification when in kill state. But doesn't execute the code to fetch data from the server. (iOS and Android)

I have achieved the same, while app is running or is in background.

I read somewhere that I may have to define a service to achieve same, but didn't quite understand it.

Will be grateful, if someone can provide their inputs.

How to create a draggable slide up panel?

$
0
0

It's nothing too elaborate, though I'm having a hard time replicating this in Xamarin Forms. As in, a view that the user can actually drag up and down.

Does Xamarin Forms have an easy solution for this problem? I've tried a bunch of libraries already and none of them seem to work/work with .Net Standard projects.

I'm currently using this solution, though it's far from perfect. Any ideas?

publish app to win store

Swagger integration with xamarin forms

$
0
0

Hello there,

I need to use swagger api codes just like drag and drop in xamarin forms project but every time I use the code generated by swagger I have to do few changes regarding restsharp and stream's writer property not found in restsharp.portable nuget package.

Please help me with the best possible solutions to fix this.

Thanks in Advance.

Two Xamarin switches alternately turn on/off

$
0
0

Hello,

I want to implement two Switches in Xamarin where one switch is on, other will automatically turn off and vice-versa. I could do this Xaml code behind as below, but I want to implement this functionality using Command or any other way to follow MVVM model. Tried to implement as Behaviors, but not successful.

Anybody has idea how to do this, thanks

Viewing all 91519 articles
Browse latest View live


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