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

App wide setttings

$
0
0

Hi

A few app wide style questions for shell app. Very sorry for asking such basic questions. I have searched a lot and there is a lot of information but I could not pick up the precise information.

How to set app wide font to Montserrat, sans-serif font family?

How to set font text foreground color in FlyoutItem?

How to set the app title that shows when it runs, both in iOS and Android? At present it shows the assembly name so instead of My App it says MyApp.

Thanks

Regards


Cross Platform Local Notification with Images

$
0
0

I'm really new to Xamarin.Forms and I want to add support for local notifications (not Push Notifications) to an app, I have tried several libraries already and I don’t find the possibility of adding images to them, I’ve been looking in the Xamarin.IOS and Xamarin.Andriod and looks like is possible to do it. I could build one library for that but I’m not too confident with Xamarin.IOS/Andriod and it would probably take a week or so, anyone knows a library for such thing?

Control Access of the User

$
0
0

Hi friends, sorry if this question is common. I'm new in this wonderful world of xamarin forms development. I tried to find some related question on forum, but I just found answers for device permission not for application permission, do you know?

I'm developing an app that will have different kind of users, like Administrators, Editors, Readers etc. I would like to restrict access for some pages in the app according the group of the user.

Do you have some material (code, tutorial, videos etc.) that you can share with me that I can learn how to reach this goal? The most part of the tutorials and videos I found in the internet is related to create the login page, but not to give or not access to specific pages, do you understand?

Any help will b appreciated.

Thanks and best regards.

Shell Application updating collectionviews MVVM

$
0
0

I am having trouble populating my collectionviews. I have switched to the Shell application tabbed project and I am using the MVVM style that came with the initial scaffolding.

My View

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="FreeScanner.Views.CategoriesPage"
             Title="{Binding Title}"
             xmlns:local="clr-namespace:FreeScanner.ViewModels"
             xmlns:model="clr-namespace:FreeScanner.Models"
             x:Name="BrowseCategoriesPage">

    <ContentPage.ToolbarItems>
        <ToolbarItem Text="Add" Command="{Binding AddCategoryCommand}" />
    </ContentPage.ToolbarItems>
    <!-- Changed on 8/12/20 per below
      x:DataType enables compiled bindings for better performance and compile time validation of binding expressions.
      https://docs.microsoft.com/xamarin/xamarin-forms/app-fundamentals/data-binding/compiled-bindings
    -->
    <RefreshView x:DataType="local:CategoriesViewModel" Command="{Binding LoadCategoriesCommand}"
                 IsRefreshing="{Binding IsBusy, Mode=TwoWay}">
        <CollectionView x:Name="CategoriesListView"
                        ItemsSource="{Binding Categories}"
                        SelectionMode="None">
            <CollectionView.ItemTemplate>
                <DataTemplate>
                    <StackLayout Padding="10" x:DataType="model:Category">
                        <Label Text="{Binding Name}" />
                    </StackLayout>
                </DataTemplate>
            </CollectionView.ItemTemplate>  
        </CollectionView>
    </RefreshView>
</ContentPage>

Code Behind for above View

using FreeScanner.ViewModels;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;

namespace FreeScanner.Views
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class CategoriesPage : ContentPage
    {
        CategoriesViewModel _viewModel;

        public CategoriesPage()
        {
            InitializeComponent();

            BindingContext = _viewModel = new CategoriesViewModel();
        }

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

ViewModel

using FreeScanner.Models;
using FreeScanner.Views;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace FreeScanner.ViewModels
{
    public class CategoriesViewModel : BaseViewModel
    {
        public ObservableCollection<Category> Categories { get; }
        public Command LoadCategoriesCommand { get; }
        public Command AddCategoryCommand { get; }

        public CategoriesViewModel()
        {
            Title = "Categories";
            Categories = new ObservableCollection<Category>();
            LoadCategoriesCommand = new Command(async () => await ExecuteLoadCategoriesCommand());

            AddCategoryCommand = new Command(OnAddCategory);
        }

        async Task ExecuteLoadCategoriesCommand()
        {
            IsBusy = true;

            try
            {
                Categories.Clear();
                var categories = await DataStore.GetCategoriesAsync();
                foreach (var cat in categories)
                {
                    Categories.Add(cat);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }

        public void OnAppearing()
        {
            IsBusy = true;
        }

        async void OnAddCategory(object obj)
        {
            await Shell.Current.GoToAsync(nameof(NewCategoryPage));
        }
    }
}

App deploys to iOS simulator but not to iPad Pro

$
0
0

I've got an App that I would like to test on my iPad Pro 12.9" (first generation, iOS 13.5.1). I am able to deploy it to a simulator but when I try to deploy it to my device Visual Studio 2019 Pro on Windows gives an error when building (not deploy):

Severity Code Description Project File Line Suppression State
Error Error while loading assemblies: /Users/paulsinnema/Library/Caches/Xamarin/mtbs/builds/eTabber.iOS/576cbcad2fb4a8344d3b1823e4c08bc2/bin/iPhone/Debug/git2-106a5f2.dll eTabber.iOS C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets 844

The path /Users/paulsinnema/Library/Xamarin/ exists but there no mtbs inside it.

Using: iPad connected via network (not cable, because the Mac Mini I'm using is in the Attic).

iOS Build
SDK Version: Automatic
Linker behavior: Link All
Supported Architecture: ARM64
HttpClient implementation: Managed (default)
Use LVVM optimizing compiler: false
Enable the Mono interpreter: true
Perform all32-bit float operations as 64-bit float: true
Strip native debugging symbols: true
Enable incremental builds: false
Use the concurrent garbage collector: true
Enable device-specific builds: false

iOS Bundle signing
Scheme: Automatic Provisioning

Build
Platform target: x64
Output path: bin\iPhone\Debug\

Send data to DB whenever user comes online

$
0
0

Hi,

I am working in Xamarin forms app. In my application I am sending data to Azure DB through Web API.
Here I am checking network,
1. When user is online data sent to Azure DB after clinking on button
2. When user is offline, data saved in mobile db and whenever user comes online, data should automatically sent to Azure DB.
I have implemented the code when user is online.

But I dont know how to implement offline mode. Please help me with this

How to get Unique id of the device

$
0
0

Hi
While installing app I want to check whether this device is registered or not, How to get unique ID of the device.

UrhoSharp: How to instanciate a urhosurface only once

$
0
0

I used this xaml example to create my urhosharp project:
https://www.xamarinexpert.it/urhosharp-tutorial-how-to-create-your-first-project-with-xamarin-forms/

The code behind is below.
Is there a way to execute

skyUrho = await urhoSurface.Show<SkyUrho>(urhoApp);

only once (in the constructor?), so that the Model is not executed from the begining when the user navigates back and shaw the page again?
I was thinking about starting a task in the constructor and awaiting it in the OnAppearing method...

    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class SkyUrhoSurface : ContentPage
    {
        private Sight currentSight;
        private SkyUrho skyUrho;
        private INavigation navigation;
        private Urho.ApplicationOptions urhoApp;

        public SkyUrhoSurface()
        {
            InitializeComponent();
            this.currentSight = null;
            urhoApp = new Urho.ApplicationOptions(assetsFolder: "Data");

        }

        protected override async void OnAppearing()
        {
            base.OnAppearing();
            skyUrho = await urhoSurface.Show<SkyUrho>(urhoApp);

            skyUrho.PageVisible = true;
            skyUrho.StarSelection = (currentSight != null);
            buttonShootThisBody.BindingContext = skyUrho;
            labelLat.BindingContext = skyUrho;
            labelLon.BindingContext = skyUrho;
            labelAltitude.BindingContext = skyUrho;
            labelAzimuth.BindingContext = skyUrho;
            labelBodysName.BindingContext = skyUrho;
            labelBodysDirection.BindingContext = skyUrho;
            labelGPSStatus.BindingContext = skyUrho;
            labelDateTime.BindingContext = skyUrho;
            activityIndicator.IsVisible = false;
            activityIndicator.IsRunning = false;
        }
        protected override async void OnDisappearing()
        {
            base.OnDisappearing();
            if (skyUrho != null)
                skyUrho.PageVisible = false;
        }
        void OnCheckBoxNamesChanged(object sender, CheckedChangedEventArgs e)
            {
                if(skyUrho!=null)
                    skyUrho.Names = e.Value;
            }
        void OnButtonShootThisBodyClicked(object sender, EventArgs args)
        {
            if(skyUrho!=null)
                if(skyUrho.SelectedStar!=null)
                    this.currentSight.StarID = (int)skyUrho.SelectedStar;
            navigation.PopAsync();
        }
    }
}

Can't access to LocalStorage from WebView

$
0
0

I'm currently developping an app where I use a WebView.
My problem is related to UWP
If my html , If I want to access a file in Assets through ms-appx-web, there's no problem, but if I want to access files in local storage through ms-appdata, it doesn't work.
I need this since the files must be on the device (no internet access), and are not constant.

Is it possible?
Thanks for help

Hervé

Migrate project from windows to mac os

$
0
0

Hello, I have migrated xamarin project from windows 10 to macos cataliina(10.15.5).

But I have a problem when I am trying to run xamarin.ios project.

/Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(5,5): Error MSB3073: The command "
if not exist "/Users/dmitry/Desktop/APP/APP_code/1.9.8/SuppClient/Portable/bin/Debug/x86" md "/Users/dmitry/Desktop/APP/APP_code/1.9.8/SuppClient/Portable/bin/Debug/x86"
xcopy /s /y "/Users/dmitry/Desktop/APP/APP_code/1.9.8/packages/Microsoft.SqlServer.Compact.4.0.8854.1/NativeBinaries/x86/." "/Users/dmitry/Desktop/APP/APP_code/1.9.8/SuppClient/Portable/bin/Debug/x86"
if not exist "/Users/dmitry/Desktop/APP/APP_code/1.9.8/SuppClient/Portable/bin/Debug/amd64" md "/Users/dmitry/Desktop/APP/APP_code/1.9.8/SuppClient/Portable/bin/Debug/amd64"
xcopy /s /y "/Users/dmitry/Desktop/APP/APP_code/1.9.8/packages/Microsoft.SqlServer.Compact.4.0.8854.1/NativeBinaries/amd64/." "/Users/dmitry/Desktop/APP/APP_code/1.9.8/SuppClient/Portable/bin/Debug/amd64"" exited with code 1. (MSB3073) (Application.Mobile.Client.Portable)

Don't have any ideas, hope for some advices.

TabbedPage How to do tabs fixed mode ?

$
0
0

My tablayout is scrollable as below , I am already using it but some pages I need fixed tabs so...

app:tabMode="scrollable"

<TabbedPage.Children>
    <local:MessagesPage />
    <local:NotificationsPage/>
</TabbedPage.Children>

Can we detect mobile phone is switched off or not in Xamarin forms

$
0
0
I want to detect user mobile phone is switched off or on. Can it be possible using Xamarin forms?

use code for dynamic data

$
0
0

hi
i have this code

public class news
{
public string image
public string image2

public list<itemnews> items 

and

 public class itemnews 
{
public string images

i want use items for carouselview that in collectionview

when i use this code meand static

 items=new list<itemnews>
{
images="https:...",
iamges="https://"
}

my collectionview show images
but i want that items show image , image 2

how can use this for dynamic data from api

Shell for first app?

$
0
0

Hi

In my very first app for Xamarin I need a relatively simple app UI wise with burger menu and single pages leading from burger menu options.

Is xamarin.forms shell the way to go for me?

Thanks

Regards

Shell custom renderer how create bottom tabbar shadow?

$
0
0

Android and ios Shell custom renderer how create bottom tabbar shadow like as same as top navigation of shadow


Discovering all devices connected to my network

$
0
0

Hi..
I want to create an app where I need to find devices connected to my wifi network using xamarin form

Images inside ListView are not loading at a time in Xamarin Forms

$
0
0

Hi,

I have an Image field inside ViewCell of ListView. I am getting the images are in the form of Byte Array, I am converting it into xamarin forms Image.

Currently I am getting 3 Images from Service, but only 2 images are displaying at a time.

I tried with FFImage Load package as well, but same problem persist.

Can anyone help on this issue.

Thanks,
Sreee

Xamarin bindable properties Lottie animation

$
0
0

I am trying to achieve an animated check box, I have created boolean property.

It is working but when focus on page from other page, animation plays from begin to end.

My purpose is to play an animation till frames are set if value is true.

Thanks in advance.

Model

public  class WishListItem
{
    public string Art_code { get; set; }
    public string ImageUrl { get; set; }

    private bool _SendRequest;
    public bool SendRequest { get => _SendRequest; set { _SendRequest = value; RaisePropertyChanged(); } }

    public event PropertyChangedEventHandler PropertyChanged;

    protected void RaisePropertyChanged([CallerMemberName] string propertyName = "")
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }
}

VM

public class WishList: INotifyPropertyChanged
{
    private ObservableCollection<WishListItem> _WishCount;

    public ObservableCollection<WishListItem> WishCount {
        get => _WishCount;
        set
        {
            _WishCount = value;
            RaisePropertyChanged();
        }
    }

    public WishList()
    {
        WishCount = new ObservableCollection<WishListItem>();
        WishCount = GetItems().Result;
    }

    public event PropertyChangedEventHandler PropertyChanged;

    protected void RaisePropertyChanged([CallerMemberName] string propertyName = "")
    {
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
    }

    public async Task<ObservableCollection<WishListItem>> GetItems()
    {
        foreach (var i in WishListService.WishListNew)
        {
            WishCount.Add(i); //Adding data 
        }

        return WishCount;
    }
}

Control

public class CustomCheckBox : AnimationView, IDisposable
{
    public string AnimationFile { get; set; }

    public CustomCheckBox()
    {
        Animation = "check.json";
        OnClick += Checkbox_OnClick;
    }

    public static BindableProperty IsCheckedProperty = BindableProperty.Create(
        nameof(IsChecked), typeof(bool), typeof(CustomCheckBox), defaultBindingMode: BindingMode.TwoWay,
        propertyChanged: IsCheckedChanged);

    public bool IsChecked
    {
        get { return (bool)GetValue(IsCheckedProperty); }
        set { SetValue(IsCheckedProperty, value); }
    }

    private static void IsCheckedChanged(BindableObject bindable, object oldValue, object newValue)
    {
        //   var cb = (CustomCheckBox)bindable;
        if (!(bindable is CustomCheckBox cb))
            return;

        if ((bool)newValue)
        {
            // cb.Play();
            cb.PlayFrameSegment(1, 50);
        }
        else
        {
            cb.PlayFrameSegment(1, 5);
            cb.IsPlaying = false;
        //    cb.Reset();
        }
    }

    void Reset()
    {
        Animation = null;
        Animation = AnimationFile;
    }

    void Checkbox_OnClick(object sender, EventArgs e)
    {
        IsChecked = !IsChecked;
    }

    public void Dispose()
    {
      OnClick -= Checkbox_OnClick;
    }
}

Xaml

<controls:CustomCheckBox x:Name="CustCheck" Grid.Row="0"  Grid.Column="1" VerticalOptions="End"                          
          IsChecked="{Binding SendRequest, Mode=TwoWay}" HeightRequest="35" WidthRequest="35" />

Attaching method to Connectivity.ConnectivityChanged EventHandler hangs when debugging on iOS

$
0
0

We're trying to check our host server reachability when the phone running our app's connectivity changes. We are using the ConnectivityChanged (EventHandler) in the Xamarin.Essentials.Connectivity class. However, when we try to attach the Connectivity_ConnectivityChanged method to the EventHandler (Line 7) it just hangs.

This is only an issue on iOS, when using VS for Windows, while debugging. Once the app is deployed on the iPhone, there is no issue

We created a test app:

We debugged this on Windows using a physical device and it attached the method successfully.

Wrap string without cutting words for thermal printer.

$
0
0

I am trying to print a string by thermal printer,but the problem is that paper accept only 32 charcters in a line and than break rest text to another line,by this last character always cut into two parts and string is hard to understand. I also use a linq mehtod to break line after 32th character but the last character is cutting. I just want after last Comma "," in first 32 characters a new line will be add by that my string will break in readable text. I am sharing my code.Thanks in advance for help..

    var PrintStr = "01-(200),02-(200),03-(200),04-(200),05-(200),06-(200),07-(200),08-(200),09-(200),10-(200),11-(200),12-(200),13-(200),14-(200),15- 
    (200),16-(200),17-(200),18-(200),19-(200),20-(200),21-(200),22-(200),23-(200),24-(200),25-(200),26-(200),27-(200),28-(200),29-(200),30-(200),31-( 
    200),32-(200),33-(200),34-(200),35-(200),36-(200),37-(200),38-(200),39-(200),40-(200),41-(200),42-(200),43-(200),44-(200),45-(200),46-(200),47-(200),48- 
    (200),49-(200),50-(200),51-(200),52-(200),53-(200),54-(200),55-(200),56-(200),57-(200),58-(200),59-(200),60-(200),61-(200),62-(200),63-(200),64- 
    (200),65-(200),66-(200),67-(200),A1111-(200)"

    var AdjustPrintStr = string.Join(Environment.NewLine, PrintStr.ToLookup(c => k++ / 32) .Select(e => new String(e.ToArray())));

output--
01-(200),02-(200
),03-(200),04-(200),05-(200),06-
(200),07-(200),08-(200),09-(200)
,10-(200),11-(200),12-(200),13-(
200),14-(200),15-(200),16-(200),
17-(200),18-(200),19-(200),20-(2
00),21-(200),22-(200),23-(200),2
4-(200),25-(200),26-(200),27-(20
0),28-(200),29-(200),30-(200),31
-(200),32-(200),33-(200),34-(200
),35-(200),36-(200),37-(200),38-
(200),39-(200),40-(200),41-(200)
,42-(200),43-(200),44-(200),45-(
200),46-(200),47-(200),48-(200),
49-(200),50-(200),51-(200),52-(2
00),53-(200),54-(200),55-(200),5
6-(200),57-(200),58-(200),59-(20
0),60-(200),61-(200),62-(200),63
-(200),64-(200),65-(200),66-(200

Viewing all 79144 articles
Browse latest View live


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