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

List inside a list

$
0
0

Hello,
I'm making a list view that contains few items, where each of those items, contains an list of other items.

            public List<GroupUsers> Users{ get; set; }

                public class GroupUsers
                {
                    public GroupUsers();

                    [DataMember(Name = "name", EmitDefaultValue = false)]
                    public string Name { get; set; }
                    [DataMember(Name = "surname", EmitDefaultValue = false)]
                    public string Surname { get; set; }
                    [DataMember(Name = "category", EmitDefaultValue = false)]
                    public List<Categories> Category{ get; set; }
                }



                    public class Categories
                    {
                        public Categories();

                        [DataMember(Name = "kind", EmitDefaultValue = false)]
                        [Discriminator]
                        public string Kind { get; set; }
                        [DataMember(Name = "period", EmitDefaultValue = false)]
                        public string Period { get; set; }
                    }

But I have problems with showing the other list in xaml

           <ListView ItemsSource="{Binding Limits}" Margin="20,20,20,20" SeparatorVisibility="None">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell Height="50">
                            <ViewCell.View>
                                <StackLayout Orientation="Horizontal">
                                    <Label Text="{Binding Name}"  />
                                </StackLayout>

                                <StackLayout Orientation="Horizontal">

                                    <Label Text="{Binding Period}" TextColor="Black" />
                                    <Label Text="----" TextColor="Black" />

                                    <Label Text="{Binding Kind}" TextColor="Black" />
                                </StackLayout>
                            </ViewCell.View>
                        </ViewCell>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

It only shows main list elements, and not the secondary list.


Errores en Xamarin.forms

$
0
0

Buenas noches, por favor su ayuda, estoy tratando de auto-educarme en el desarrollo de app multiplataformas por lo que me intereso mucho aprender Xamarin, pero me estoy dando contra las paredes porque no logro entender porque me salen tantos errores con solo crear un proyecto nuevo, he revisado tutoriales, he leilo parte de libros pero no logro dar en solucionar el error, no se si haya sido un error al instalar el xamarin porque sin codificar nada aun salen esos errores de las referencias, adjunto imágenes esperando puedan encaminarme en la solución.

Google Login doesn't redirect back to app

$
0
0

Well, First then nothing, I don't speak english very well..

My problem is the next, I'm trying to implement a Google Login in my app, with next two references:
1. https://jorgediegocrespo.wordpress.com/2018/12/19/login-en-google-desde-xamarin-forms/
2. timothelariviere.com/2017/09/01/authenticate-users-through-google-with-xamarin-auth/

Well, when I select a google account the next page that appear "google.com", and I dontn't knows why.

First: OPEN THE NATIVE BROSER

Seccond: com.companyname.Auth, is my package android name in the AndroidManifest.xml

Next, When I select an account appear this page with a label "Espera un momento ~ Wait a moment"

And for last appear the Google homepage and don't return to my App :(

When I close the Navigation native Browser appear this Message

In Google Developer Console my OAth Consent Screem is this:

When I call the OAth2 Constructor the redirect URL than i use is this:
com.companyname.Auth:/oauth2redirec

My Source is the same than the first url reference:

I used in one moment the video tutorial of Houssem Dellai...

https://youtube.com/watch?v=AgFIsVr26zg

In his tutorial he uses a webview in the shared code, but i readed that google don't admit this solution now, and when i run the webview i have another error from Google.

I don't understand what is my problem.. i have several days trying this :( please help!!

How to add background service in Xamarin forms

$
0
0

I am new developer in xamarin,
That's why i faced some problem.
I can't create background service in (PCL) Android, iOS and also UWP.

Anybody help me to give example code or station.

Collectionview selected item on appear

$
0
0

Hi All,

I have a problem with a collection view, I need simply that when my collection view is populated then select one item this is my code

ViewModel

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using MerkurWinApp.Models;
using MerkurWinApp.Services;
using MerkurWinApp.Views;
using Newtonsoft.Json;
using Xamarin.Forms;

namespace MerkurWinApp.ViewModels
{
public class BetViewModel: BaseViewModel
{
public event PropertyChangedEventHandler PropertyChangedBet;
private ObservableCollection _sportsBet;
public Command LoadTournamentsNavigation { get; set; }

    public BetViewModel()
    {
        Title = "Scommesse";
        _sportsBet = new ObservableCollection<Sport>();
        LoadTournamentsNavigation = new Command(async () => await ExecuteLoadTournamentsNavigation());
    }

    public ObservableCollection<Sport> SportsBet
    {
        get
        {
            return _sportsBet;
        }
        set
        {
            if (_sportsBet != value)
            {
                _sportsBet = value;
                OnPropertyChanged(new PropertyChangedEventArgs("SportsBet"));
            }
        }
    }

    Sport selectedSportBet;

    public Sport SelectedSportBet
    {
        get
        {
            return selectedSportBet;
        }
        set
        {
            SetProperty(ref selectedSportBet, value);
            OnPropertyChanged(new PropertyChangedEventArgs("SelectedSportBet"));
        }
    }

    async public Task ExecuteLoadTournamentsNavigation()
    {
        if (IsBusy)
            return;

        IsBusy = true;

        RestService rest = new RestService(false);

        var result = await rest.GetDataAsync(Endpoints.TournamentTree);

        if (!result.ContainsKey("result"))
        {
            try
            {
                SportsAamsList _sportsAams = new SportsAamsList();
                var assembly = typeof(MainPage).GetTypeInfo().Assembly;
                Stream stream = assembly.GetManifestResourceStream($"{assembly.GetName().Name}.{"SportsAAMS.json"}");
                using (var reader = new System.IO.StreamReader(stream))
                {
                    var jsonString = reader.ReadToEnd();

                    _sportsAams = JsonConvert.DeserializeObject<SportsAamsList>(jsonString);
                }

                var json = JsonConvert.SerializeObject(result);

                var res = JsonConvert.DeserializeObject<TournamentsTree>(json.ToString());
                _sportsBet.Clear();
                foreach (KeyValuePair<string, Sport> row in res.Sports)
                {
                    SportsAams v = _sportsAams.sportsAamsList.Find(x => x.SportName == row.Value.Name);
                    if (v != null)
                    {
                        row.Value.IconName = v.IconName;
                    }

                    int numBadge = 0;

                    foreach (var cat in row.Value.Categories)
                    {
                        numBadge += cat.Value.Tournaments.Count;
                    }

                    row.Value.BadgeCount = numBadge.ToString();

                    _sportsBet.Add(row.Value);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }
    }

    private void OnPropertyChanged(PropertyChangedEventArgs eventArgs)
    {
        PropertyChangedBet?.Invoke(this, eventArgs);
    }
}

}

Page

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using MerkurWinApp.Models;
using MerkurWinApp.ViewModels;
using Xamarin.Essentials;
using Xamarin.Forms;

namespace MerkurWinApp.Views
{
public partial class BetPage : ContentPage
{
BetViewModel viewModel;
public BetPage()
{
InitializeComponent();
BindingContext = viewModel = new BetViewModel();
}

    protected override void OnAppearing()
    {
        base.OnAppearing();

        if (viewModel.SportsBet.Count == 0)
        {
            viewModel.LoadTournamentsNavigation.Execute(null);

        }
    }

    void MainNavigation_SelectionChanged(System.Object sender, Xamarin.Forms.SelectionChangedEventArgs e)
    {
        var previous = e.PreviousSelection as ContentView;
        var current = e.CurrentSelection as ContentView;
    }
}

}

XAML

<?xml version="1.0" encoding="UTF-8"?>

<ContentPage.ToolbarItems>

</ContentPage.ToolbarItems>
<ContentPage.Content>

<Grid.RowDefinitions>


</Grid.RowDefinitions>



<ListView.ItemTemplate>


</ListView.ItemTemplate>



</ContentPage.Content>

Please can you help me?

Thanks.

MasterDetail page drop shadow on detail

$
0
0

Is there anything that I need to do in iOS to get the drop shadow like in Android for the detail Window?

iOS doesn't seem to have that:

Xamarin forms: How to develop applications for Amazone Fire TV

$
0
0

We are planning to create an application for amazon fire os devices like Amazon Fire tablets, Amazon Fire phone, Amazon Fire TV and the Amazon Fire TV Stick using Xamarin forms. I research about this and found this blog. But I am using visual studio for the development. So is there any NuGet packages available for this? I checked the Android SDK Manager, like the blog not found amazon fire tv SDK under API 17. Also, How can I use the Amazon Fire TV component?

Our app is a simple app for listing the videos based on the category, also has a login page. Is it possible to use the same project for Chromecast and rokoo players? Should I include other packages or components for them?

Please provide me with a starting point for what I have to do.

How to change picker color in xamarin forms?

$
0
0

Hey Everyone,
I want to change the color of picker as it has a default color i.e. white

Is there any way to change the color white to black?

Thanks


How to use custom font in shared library

$
0
0

I have several xamarin forms applications using a single .net standard library with many shared components to maintain look and feel.

How do I go about setting up a custom font on these controls so it is configured in one central location. I have read through several articles like which all mention editing the plist file and copying files in the specific android/ios assets directories.

Is there a way to do this in a centralised library? How would a third party component library go about doing this?

I have so far added my two fonts (open sans) to /Assets/Fonts folder in my shared lib, set the build action to "content" and copy to output directory to "copy if newer" I see them appear in my bin folder.

I have a resource dictionary referencing these:

<ResourceDictionary
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="AlloyMobileComponents.Resources.FontResources">
  <!-- see /Assets/Fonts for font files -->
  <OnPlatform
      x:TypeArguments="x:String"
      x:Key="NormalFont">
    <On
        Platform="Android"
        Value="Assets/Fonts/OpenSans-Regular.ttf#Open Sans" />
    <On
        Platform="iOS"
        Value="OpenSans-Regular" />
  </OnPlatform>
  <OnPlatform
      x:TypeArguments="x:String"
      x:Key="BoldFont">
    <On
        Platform="Android"
        Value="Assets/Fonts/OpenSans-Bold.ttf#Open Sans" />
    <On
        Platform="iOS"
        Value="OpenSans-Bold" />
  </OnPlatform>
</ResourceDictionary>

And I consume this in my components using {DynamicResource BoldFont} etc.

Solution cleaned, rebuilt and run and I get:

**Java.Lang.RuntimeException:** 'Font asset not found Assets/Fonts/OpenSans-Bold.ttf'

any ideas?

How I can carry GoogleMobAd Bellow Shell

$
0
0


I Used Shell And I Have Ad,How Can I Show Ad Below Shell

menu entry that comes from the bottom up, what can I do?

$
0
0

Good Morning,
I need to create a menu for the settings that clicked a button comes out from the bottom up, how could I do? is there any component or library that can help me?

Xamarin iOS app is not able to execute code when it is minimized

$
0
0

Hello Everyone,

I have a chat application, developed on the Xamarin.Forms platform, in which users can chat with each other. I have managed c# code and UI both in the shared project.

I have been facing problem since long in iOS platform. When the iOS app is running on screen, having foreground mode then the app can successfully receive a message which has been send by another user. When the app is running in the background mode and someone sends a message, I want to notify the user by using local notification (No Push remote notification - Because I think as my app is already running in minimized mode there is no need to wake up the app by implementing Push notification). Even I have implemented local notification successfully but the problem is,

When the iOS application heads to the background mode, the main thread (task) is paused so, when some user sends a message the app is not able to execute the code (when app is minimized) so that it won’t be able to show the local notification. But when the application is brought back to the foreground the thread/task get resumed and then ie shows up the local notification and also the message.

I already have selected the "Background fetch" property under Background Modes in Info.plist. I have also added below the line in my FinishedLaunching method
UIApplication.SharedApplication.SetMinimumBackgroundFetchInterval(UIApplication.BackgroundFetchIntervalMinimum);

I have already worked and implemented different code for backgrounding, but didn’t worked for me.

I think my issue is relate to iOS Background processing, So, does anyone has idea what to do, to execute the code when app is already in minimized mode?

PDF / Word / Document (?) creation

$
0
0

Hi everyone, i'm developing a simple app with Xamarin.Forms for Android, iOS and UWP.
My goal is to generate a document (PDF or Word or anything else that's printable) but i can't find any way to do it.

Does anyone know any compatible free plugin?

Thanks in advance

Xamarin Forms Android Frame Renderer and Corner Radius

$
0
0

When I create a custom renderer for Xamarin Forms Frame in Android, CornerRadius property goes for a toss. No matter what I set it to, it doesn't work. It always draw a rectangle.

Xamarin Forms (Control) -

public class MyFrame : Frame
{
}

Xamarin Forms (XAML) -

<shd:MyFrame WidthRequest="200" HeightRequest="200" CornerRadius="100">
    <shd:MyFrame.Content>
        <Label Text="Hello" TextColor="Black"/>
    </shd:MyFrame.Content>
</shd:MyFrame>

Xamarin Android -

public class MyFrameRenderer : ViewRenderer<Controls.MyFrame, FrameRenderer>
{
    public MyFrameRenderer(Context context) : base(context)
    {

    }

    protected override void OnElementChanged(ElementChangedEventArgs<Controls.MyFrame> e)
    {
        base.OnElementChanged(e);

        if (e.NewElement != null)
        {
        }
    }
}

How do I set CornerRadius property to give it rounded corners.

Thanks!

Keep the header-row of a listview from scrolling

$
0
0

Hi :)
Does anybody know, if there is a way to keep the header-row in a listview from scrolling? --> I only want
the data-rows to be scrollable.

I attached my code as a picture, since it did not show correctly when I pasted it here.

Friendly regards:
nbs


NavigationPage.SetHasNavigationBar without animation?

$
0
0

Hello

I want to hide the NavigationBar without animation. Is that possible and if can you told me how?

How to hide the NavigationBar
NavigationPage.SetHasNavigationBar(this, false);

BindingContext Doesnt update my scrollView

$
0
0

Hi, I have somtehing like calendar, this calendar loads on button click, but after this click I want to scroll this calendar to the end of this loaded list, but it doesnt update, and if I had 20 items i still have 20 not 27. I have 27 after next click.

 if (calender.ScrollX < 10 && CrossConnectivity.Current.IsConnected)
            {
                var position = calender.ScrollX;
                var Length = calender.ContentSize.Width;
                var viewModel = (CalendarViewModel)BindingContext;
                if (viewModel.LoadLeftList.CanExecute(null))
                {
                    await Task.Run(() => viewModel.LoadLeftList.Execute(null));
                }

                var lastStack = (StackLayout)calendarStackList.Children[0];

                await calender.ScrollToAsync(lastStack, ScrollToPosition.Start, false);

                var mainStackDate = (StackLayout)calendarStackList.Children[_indexOfFrame + MainConsts.GetNumberOfDates];
                var mainFrame = (Frame)mainStackDate.Children.First();
                mainFrame.BackgroundColor = Color.FromHex("#4074DD");

                _lastClickedFrame = mainFrame;
            }
private async void LeftList()
        {
            if (!CrossConnectivity.Current.IsConnected)
            {
                return;
            }

            try
            {
                var datesSet = await MeetingService.GetMeetingsStatusesForDays(new GetMeetingsStatusesForDaysApi
                {
                    Date = CalendarDates.First().EntireDate,
                    Days = MainConsts.GetNumberOfDates,
                    GetDateType = GetDateType.Left
                });

                CalendarDates = datesSet.Concat(CalendarDates).ToList();
                RaisePropertyChanged(nameof(CalendarDates));
            }
            catch (Exception e)
            {
                await LogService.LogAsync(e);
            }           
        }

So if you can see await Task.Run(() => viewModel.LoadLeftList.Execute(null)); this loads my list, but calendarStackList.Children is still same number, how to handle this ?

ListView GroupHeaderTemplate fixed height on iOS

$
0
0

Hey there guys, I'm trying to set a variable height list view on iOS. Our code (on the attached sample project and main part below) works fine on Droid, but fails miserably on iOS.
I have tried iOS 9.3 and iOS 10, with forms 2.3.2.127 and latest prerelease 2.3.3.163-pre3.

<ListView Grid.Row="2"
        ItemsSource="{Binding MenuSections}"
        IsGroupingEnabled="True"
        HasUnevenRows="True"
        SeparatorVisibility="Default"
        ItemTapped="ListViewOnItemTapped">
 
<ListView.GroupHeaderTemplate>
    <DataTemplate>
        <ViewCell>
            <StackLayout Padding="15,10,15,10"
                         Spacing="0"
                         BackgroundColor="Green">
                <Label Text="{Binding Name}"
                        LineBreakMode="TailTruncation"
                        TextColor="White"
                        FontSize="14"/>
 
                <Label Text="{Binding Description}"
                        Margin="0,0,0,10"
                        IsVisible="{Binding HasDescription}"
                        LineBreakMode="WordWrap"
                        TextColor="{StaticResource BSDirtyWhite}"
                        FontSize="11"/>
            </StackLayout>
        </ViewCell>
    </DataTemplate>
</ListView.GroupHeaderTemplate>

 
I have already removed everything above with only a Label, and got exactly same result. Looks like header height on iOS is fixed to some constant number.

Please also find attached the screen shots for Droid (working fine) and failed iOS 9.3 and 10.

Any help or workaround is greatly appreciated.
NightOwl

how to import an object in urhosharp

$
0
0

Hello,
I made made progress in my planetarium project: I know how to add urhosharp in my xamarin.forms project and how to show lines and write text. But I need to receive a boost.

The purpose is to make a planetarium. The user sees stars and can click on a star to select it and get informations.
I made a 3D scene with blender and python scripting with white filled circles around a sphere (500 stars are at the good position, facing the center). The light and the camera are in the center of the scene (see picture). I can render it.

Next, I need to import the objects in my xamarin.forms project.

These are few questions. If an Urhosharp expert could give me few indications, it could be great.

  1. I need to use Assetimport to convert my scene. Can I convert a full node with all the circles in it. Is there any step by step documentation ?
  2. what will I get? a xml file? 500 xml files? a mdl file?
  3. where should I copy these files to import them in my project?
  4. how can I import them in my code, what is the path?
  5. how can I import in my project a blender made material?
    I made python scripting in blender to draw the sky.
  6. would it be a better (faster or easier) solution to draw the sky in C# in the app?
  7. would it be a better (faster or easier) solution to draw the sky in urho editor with angelscript?

Thank you for your help and your advices

print a png in a urhosharp project

$
0
0

Hello, I asked this question in the "Libraries, Components, and Plugins" forum but maybe I will find an answer here.

My purpose is to make a planetarium. So I need to draw the stars and lines (constellations, meridians, ecliptic, etc).
For the stars and planets I would like either to print a png at the coordinates of the stars or draw a disk or a circle.
The documentation for urhosharp is very light so I don't know which would be the best solution.

My idea is to put the camera at the center of the scene (0,0,0) looking at any direction and to draw .PNGs or disks all around.
Should I create a square with the png as a texture? draw a sprite2D?
Can I put the light behind the camera in the same direction?

Thank you for your help.

Viewing all 91519 articles
Browse latest View live


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