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

Can we Run a task(sending the data to server) in background when app killed(InActive) in IOS?


Displaying all images inside FlowListVIew

$
0
0

Hi Xamarin Forum
does anyone already used FlowlistView to display images from recorded file path in database and display the image in a tile design just like instagram?

ListView Grouping With Sqlite Database

$
0
0

Hi there,
I am having a little trouble grasping the concept of how to group with the ListView.
I have a user table and I have an exerciselog table
here are my models:
public class UserTbl
{
[PrimaryKey]
public string userID { get; set; }
public string Email { get; set; }
public string fullName { get; set; }
//There are other fields but they don't matter at this point
}
public class ExLogTbl
{
[PrimaryKey][AutoIncrement]
public int exerciseLogID { get; set; }
public string userID { get; set; }
public int exerciseID { get; set; }
public string exerciseName { get; set; }
}

//model to combine the data for listview

 public class ExerciseWithUserInfo
    {
        public string userID { get; set; }
        public string Email { get; set; }
        public string fullName { get; set; }
        public int exerciseLogID { get; set; }
        public int exerciseID { get; set; }
        public string exerciseName { get; set; }
    }

What I would like to do is group the exercises by user.
In my ExerciseWithUserInfo class I added an additional class that should (from what I have been reading) allow me to group. All properties to show in the group header start with "grp"

public class ExerciseWithUserInfoHead : ObservableCollection<ExerciseWithUserInfo>
    {
        [Column("userID")]
        public string grpUserID { get; set; }
        [Column("fullName")]
        public string grpFullName { get; set; }
        [Column("Picture")]
        public string grpPicture { get; set; }
        public ObservableCollection<ExerciseWithUserInfo> groupedList => this;
    }

Here is where I am not so sure how this should work. Can I just pull the same query to populate to make a list with ExerciseWithUserInfoHead and then pull a query to make a list with ExerciseWithUserInfo and then add the ExerciseWithUserInfo list to the ExerciseWithUserInfoHead list and then set the GroupDisplayBinding to the userID? I am not sure of of the inner workings of grouping but it seems like it wouldn't know what goes with what.
I was thinking that I need to first pull a list with distinct who have exercises and then foreach item query pull the exercise details and add it that way.
Any thoughts?
Thank you,
Rob

Notification similar whatsapp

$
0
0

I have to implement this type of notification similar to whatsapp

I have two questions to ask.

1)what kind of notification is it?

Toast??
developer.android.com/guide/topics/ui/notifiers/toasts

Or Expandable Notification?????
developer.android.com/training/notify-user/expanded

2) is this type of notification an android standard or is it a personalization of samsung mobile phones?

Weird behavior of custom content view in Array Markup Extension

$
0
0

I am trying to instantiate a CarouselView by XAML like this:

            <CarouselView Grid.Row="1"
                          Grid.ColumnSpan="3"
                          CurrentItemChanged="CurrentItemChanged">
                <CarouselView.ItemsSource>
                    <x:Array Type="{x:Type views:ItemCollectionView}">
                        <views:ItemCollectionView Items="{Binding Orders}"/>
                        <views:ItemCollectionView Items="{Binding Invoices}"/>
                        <views:ItemCollectionView Items="{Binding Returns}"/>
                    </x:Array>
                </CarouselView.ItemsSource>
            </CarouselView>

Not only do the bindings not seem to work as they stay null even after setting the BindingContext to my VM, I am unable to give the views inside the Array an x:Name.

Furthermore they display very weirdly as shown here:

Has anyone any guidance on these problems? Should I simply instantiate my array in code?
Thank you

Get clicked event in custom control button

$
0
0

How i can get clicked event when click on my custom button?
I’ve already tried everything, it still doesn’t work.
I wants change string when click on button

 public class ButtonStates : Button
    {

        public static readonly BindableProperty EnableButtonColorProperty = BindableProperty.Create(nameof(EnableButtonColor), typeof(Color), typeof(ButtonStates), Color.Default, BindingMode.OneWay, null, null, null, null);
        public static readonly BindableProperty DisableButtonColorProperty = BindableProperty.Create(nameof(DisableButtonColor), typeof(Color), typeof(ButtonStates), Color.Default, BindingMode.OneWay, null, null, null, null);
        public static readonly BindableProperty NormalButtonColorProperty = BindableProperty.Create(nameof(NormalButtonColor), typeof(Color), typeof(ButtonStates), Color.Default, BindingMode.OneWay, null, null, null, null);
        public static readonly BindableProperty ButtonStateProperty = BindableProperty.Create(nameof(ButtonState), typeof(int), typeof(ButtonStates), null);
        public static readonly BindableProperty ButtonStringProperty = BindableProperty.Create(nameof(ButtonString), typeof(string), typeof(ButtonStates), null);

        public ButtonStates()
        {
            var tapGestureRecognizer = new TapGestureRecognizer();
            tapGestureRecognizer.Tapped += TapGestureRecognizer_Tapped;
            GestureRecognizers.Add(tapGestureRecognizer);
        }

        //public event EventHandler Clicked;

        private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
        {
                ButtonState++;
                if (ButtonState == 0)
                {
                    BackgroundColor = NormalButtonColor;
                    ButtonString = null;
                }
                else if (ButtonState == 1)
                {
                    BackgroundColor = EnableButtonColor;
                    ButtonString = ButtonString;
                }
                else
                {
                    BackgroundColor = DisableButtonColor;
                    ButtonString = $"!{ButtonString}";
                }
        }
        public int ButtonState
        {
            get => (int)GetValue(ButtonStateProperty);
            set => SetValue(ButtonStateProperty, ButtonState);
        }

        public string ButtonString
        {
            get => (string)GetValue(ButtonStringProperty);
            set => SetValue(ButtonStringProperty, ButtonState.ToString());
        }
}

An exception occurred while rendering the control.

$
0
0

when i create sqliteconection then An exception occurred while rendering the control.
please help me ASAP

Rest Api Https Reqest (The certificate authority is invalid or incorrect)

$
0
0

Hello,

I'm trying to get simple json data from my linux SSH remote server (UWP, Android) but it refuse to respond to my App.

But i'm confused why i can get the data when i send the request with my browser(with not secure warning) or through Postman(with Settings option: SSL certificate Off) ??

I'm wonder how could i resolve this, how can i avoid certificate authority and get the data (just like in Postman), and how shall i actually have to deal with SSL certification in my HTTPS reqeust. My server support OpenSSL.

MAIN SEGMENT OF MY CODE:

    HttpClient client = new HttpClient();
    var response = await client.GetStringAsync("https://" +  ServerApiLinkConnection);
    Debug.WriteLine(response);

ERROR:

    System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Exception: The text associated with this error code could not be found.

    The certificate authority is invalid or incorrect

       at System.Net.Http.HttpHandlerToFilter.SendAsync(HttpRequestMessage request, CancellationToken cancel)
       at System.Net.Http.HttpClientHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
       --- End of inner exception stack trace ---
       at System.Net.Http.HttpClientHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
       at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
       at System.Net.Http.HttpClient.GetStringAsyncCore(Task`1 getTask)

Binding with StringFormat only works after hot reload!

$
0
0

When the page appears, the label becomes invisible:
<Label Text="{Binding NoDays, StringFormat={local:Translate workingDays}}"/>
but if I issued a hot reload (for example; typing a space after the end tag and then save)
the text is shown with the correct format!

A bug?!

Play video UWP

$
0
0

I am using the following code to open a video in the UWP part of a Xamarin forms App.

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

        try
        {
                var mainDir = FileSystem.AppDataDirectory;
                string filepath = Path.Combine(mainDir, "CCapture.mp4");
                if (File.Exists(filepath))
                    CrossMediaManager.Current.Play(filepath);
        }
        catch (Exception ex)
        {
            string errMessage = ex.Message;
        }

When I navigate to screen I can see the player but no video is displayed. If I use a http url it works.

Any help would be appreciated.

Set different external storage path for xam.plugin.media?

$
0
0

I would like to save the photos in the private folder of the application (android/data/com.companyname...) on the SD card and not on emulated/0/Android/data/... Is it possible to change this parameter or do I have to create my own custom camera?

I get the path from Context.GetExternalFilesDirs list

Thanks

Use HockeyApp and App Center (sdk's) simultaneously

$
0
0

Scenario:

  • xamarin.insights will be fully retired at the end of this month
  • The transition from Hockeyapp to App Center is not fully completed

I'm trying to migrate gradually to App Center so the decision would be to use (at first) App Center only for logging errors and continue to use Hockeyapp for distribution.

For the android version all works fine instead I wasn't able to build the ios version. The reason is that the two sdk are in conflict.
Any suggestion?

Error

Native linking error: 1 duplicate symbol for architecture i386
obj/iPhoneSimulator/Debug/mtouch-cache/AppCenterCrashes.a(MSCrashesCXXExceptionHandler.o
obj/iPhoneSimulator/Debug/mtouch-cache/libHockeySDK.a(BITCrashCXXExceptionHandler.o
Native linking failed, duplicate symbol: '___cxa_throw'

Xamarin Forms & Augmented Reality

$
0
0

Are any recent samples available with Xamarin Forms on GitHub, etc. to target iOS, Android with displays of augmented reality?

Thanks in advance for any insight, guidance;

Listview binding

$
0
0

Hi, I have been trying to set-up binding with my Listview. Unfortunately the data doesnt show up but I don't have a clue what is wrong. The observ. collection does has 86 items.
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="" xmlns:x="" xmlns:d="" xmlns:mc="" mc:Ignorable="d" x:Class="DestinationsApp.MainPage"> <ContentPage.ToolbarItems> <ToolbarItem Text="test" Priority="0"/> <ToolbarItem x:Name="tbAddDestinyPage" Text="+" Activated="tbAddDestinyPage_Activated"/> </ContentPage.ToolbarItems> <ListView ItemsSource="{Binding Destinies}" SeparatorColor="Black" BackgroundColor="GreenYellow"> <ListView.ItemTemplate> <DataTemplate> <TextCell Text="{Binding City}" TextColor="Black"/> <!--<ViewCell> <StackLayout Orientation="Horizontal"> <Label Text="{Binding Country}"/> <Label Text="{Binding City}"/> <Label Text="{Binding Type}"/> </StackLayout> </ViewCell>--> </DataTemplate> </ListView.ItemTemplate> </ListView> </ContentPage>
CS:
``
using DestinationsApp.Classes;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace DestinationsApp
{
[DesignTimeVisible(false)]
public partial class MainPage : ContentPage
{
public ObservableCollection Destinies { get; set; }

    public MainPage()
    {
        BindingContext = this;
        InitializeComponent();
        Destinies = new ObservableCollection<Destiny>();
        RetrieveDestinies();
    }

    private void tbAddDestinyPage_Activated(object sender, EventArgs e)
    {
        Navigation.PushAsync(new AddDestinyPage());
    }

    private async void RetrieveDestinies() {

        ApiResponse arResponse = await ApiWrapper.RetrieveDestinies();

        foreach (Destiny destiny in arResponse.Destinations)
        {
            Destinies.Add(destiny);    
        }

        Console.WriteLine(Destinies);
    }
}

}
``

Class:
``
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Text;

namespace DestinationsApp.Classes
{
public class Destiny : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged([CallerMemberName] String propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private string _ID;

    public string ID
    {
        get { return _ID; }
        set { _ID = value; OnPropertyChanged(nameof(ID)); }
    }

    private string _Country;

    public string Country
    {
        get { return _Country; }
        set { _Country = value; OnPropertyChanged(nameof(Country)); }
    }

    private string _City;

    public string City
    {
        get { return _City; }
        set { _City = value; OnPropertyChanged(nameof(City)); }
    }

    private string _Type;

    public string Type
    {
        get { return _Type; }
        set { _Type = value; OnPropertyChanged(nameof(Type)); }
    }
}

}
``

Java.Net.ProtocolException: 'unexpected end of stream' I got this error.

$
0
0

I am using Android Device manager "Pixel 2 Pie 9.0 – API 28"

i try to input my Xamarin form app value to Sql server table using Asp.net Api but not working with "Java.Net.ProtocolException: 'unexpected end of stream' I got this error."

please tell me any solution or any link. help me!

Thank you.


Prism DialogService questions

$
0
0

I am trying to implement the DialogService in my application to (1) display an alert and do something with the result and (2) display a busy mask while doing background work. My dialogservice is defined in the viewmodel since I want to use this in all my viewmodels.

https://github.com/rezamohamed/SfBusyIndicator

~~(1) I am a little confused on how to use the dialogservice to do something based on the user interaction, in my code, the dialogservice appears and I return a result based on the user click, however, it seems that the dialogservice doesn't really wait for the user interaction to finish.

what I want to happen: Show Dialog -> user presses Accept or Decline -> based on that interaction do something in the caller method

    private void ShowPopup()
    {
        var result = DisplayAlert("message from Main View Model");

        ReturnMessage = result;

    }

In the above case, the alertdisplays, and then immediately the ReturnMessage = result is executed (to start its empty, if i press the Show Popup again, it displays what was in the result field prior. How do I wait for user interaction?~~

(2) I would like to show the dialog from a caller method, and also close the same dialog from the caller method...like a busy indicator. I can show the alert, but I am unclear on how to close this from the caller method. There is a DialogeService.ShowDialog(...), but there isn't a simlar DialogService.CloseDialog(..) or something like that.

what I want to happen: Show Busy from a method -> same method makes api calls etc, doing busy work -> once busy work is over, close the dialog

(3) this is more me confusing myself on base classes, so I apologize in advance. Currently I am creating a Base View Model where I am using the Prism DialogService. The dependency service is injected in app.xaml.cs.

    public ViewModelBase(INavigationService navigationService, IDialogService dialogService)
    {
        NavigationService = navigationService;
        DialogService = dialogService;

    }

I am only using the DialogService directly from my Base ViewModel, but since all my other viewmodels derive from this base, I have to call the base constructor as well and pass a DialogService. this feels redundant if I am going to be using the same DialogService across all my viewmodels, can I get away from not having to declare and pass the dialog service in all my derived viewmodels and only define it in my base view model, in some sense, I am asking the same for the navigation service as well.

ie. not having to pass navigationService and dialogService in every derived viewmodel because its the same. this is how I currently have it.

    public MainPageViewModel(INavigationService navigationService, IDialogService dialogService)
        : base(navigationService, dialogService)
    {

        Title = "Main Page";
    }

How Can I Set A Grid RowDefinition Height Through A Dynamic Resource?

$
0
0

I have an application where I need to set row heights on a grid based on device size?

I have a method that checks for the device's resolution, and then applies a unique resource dictionary based on whether it's a small screen, large screen or tablet.

My grid uses asterisk value to manage the three rows, is there a way to add the asterisk value like I manage strings, doubles and font sizes in a dictionary? Or is there a different/better way to manage the relative sizes for the three device sizes?

How to include Microsoft.Services.Store.SDK with MSBuildSdkExtras type of plugin

$
0
0

I am creating a plugin using MSBuildSdkExtras with the PluginForXamarinTemplates. In uwp, i need to include Microsoft.Services.Store.SDK as reference but i cant figure it out. here is what i tried. But it complains as shown in the screenshot. How can this work in this MSBuildSdkExtras style?

  <ItemGroup Condition=" $(TargetFramework.StartsWith('uap10.0')) "> 
    <Compile Include="**\*.uwp.cs" />
    <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.2.9" />      
    <PackageReference Include="Microsoft.Services.Store.Engagement" Version="10.1901.28001" /> 
    <PackageReference Include="Microsoft.Services.Store.SDK" Version="10.1705.16001" />
    <SDKReference Include="Microsoft.Services.Store.Engagement, Version=10.0">
      <Name>Microsoft Engagement Framework</Name>
    </SDKReference>
    <SDKReference Include="WindowsDesktop, Version=10.0.18362.0">
      <Name>Windows Desktop Extensions for the UWP</Name>
    </SDKReference>
  </ItemGroup>

Issue rendering UIDatePicker on iPhone XS and 11plus only

$
0
0

I have a Forms project that needs a combined date & time picker, so off to the custom renderer land I went. Things seemed fine when I was testing on my iPhone 8 Plus test device, but on an iPhone XS or 11 Pro (physical devices, both on 13.3) the picker does not render correctly - all the dates are greyed out, and time is completely invisible. I played with the forms side layout as well as UIDatePicker properties, but nothing had any effect on the rendering issues on newer iOS devices. Unsurprisingly, the simulator for both those devices renders correctly. The entire sample project can be found on GitHub, esenciadev/DatePickerTest (I registered a new account to post this and so cannot post a direct link, apologies)

Page:

<StackLayout Orientation="Vertical" Margin="8,16,8,16">
    <Label Text="This is just a test"
       HorizontalOptions="Center"
           Margin="8,16,8,16"
       VerticalOptions="Start" />
    <local:MyDatePicker Date="{Binding Date}"
                        Margin="8,16,8,16"
                        DateChangedCommand="{Binding DateChangedCommand}"
                        VerticalOptions="FillAndExpand"
                        HorizontalOptions="FillAndExpand"/>
    </StackLayout>

Relevant code from the renderer:

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

    if (e.OldElement != null)
    {
        _datePicker.ValueChanged -= DatePickerOnValueChanged;
    }

    if (e.NewElement != null)
    {
        if (Control == null)
        {
            _datePicker = new UIDatePicker(new CGRect(
                e.NewElement.Bounds.X,
                e.NewElement.Bounds.Y,
                e.NewElement.Bounds.Width,
                e.NewElement.Bounds.Height
             ));
            _datePicker.Mode = UIDatePickerMode.DateAndTime;
            _datePicker.Date = (NSDate) Element.Date;
            _datePicker.MaximumDate = (NSDate) Element.Date.AddDays(1);
            _datePicker.MinimumDate = (NSDate) Element.Date.Subtract(TimeSpan.FromDays(5));
            _datePicker.MinuteInterval = 1;

            SetNativeControl(_datePicker);
        }

        _datePicker.ValueChanged += DatePickerOnValueChanged;
    }
}

PropertyChanged.Fody Is Not Working When Switch To Release Build

$
0
0

im using latest xamarin with propertychanged.fody, i can access object in viewmodel debug build and manipulate in methods in viewmodel, but after switch to release build, apps suddenly crash after i clicked command button which was bind in viewmodel.

Viewing all 77050 articles
Browse latest View live


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