Is there a way to limit the length of text in an Entry control? If not, is it planned to add this feature?
Max length on Entry
Mysterious error when trying to embed Xamarin.Forms into Xamarin Android
Hello there, I have an application that I am building with both Xamarin iOS and Xamarin Android heads. I have some more screens to add that really could be shared, so I decided to see about using this nifty Xamarin Forms embedding capability. I have installed Xamarin forms in my Android and iOS projects as well as a PCL. In the PCL, I created a new ContentPage that is just a ScrollView with a single Label in it that I want to use to test things out.
In my Xamarin Android project's Main Activity, I initialize Xamarin.Forms successfully in OnCreate. Then I successfully create my ContentPage. When I go to generate a Fragment to swap into my Activity, I get the error: "element is not of type Xamarin.forms.view".
At first, I guessed it had to do with something in my ContentPage XAML or maybe in the layout of the Android activity, but I have tried everything I can think of to switch layouts/views contained in each to get it to work. Has anyone had this type of issue when using Xamarin Forms embedding? It's getting to the point where I think that it isn't worth the hassle to avoid making multiple native versions of these screens.
Thanks!
FCM push notifications issue
I have followed this guide to the letter: https://blog.xamarin.com/implementing-push-notifications-android-apps/
But all i get is this:
06-27 11:40:46.376 I/FirebaseInitProvider( 4568): FirebaseApp initialization unsuccessful
Any further insights regarding said tutorial? Thank you!
Vertical Scroll Inside Editor Box
Hi All,
I have one Editor box and i want Vertical scroll inside editor box.
Thanks in advance.
Xamarin.Forms PDF Viewer Options
Hi,
I know this has been asked and discussed before. However, there doesn't seem to be a good consensus on the subject. What I'd like to know from a few Xamarin experts here is.. what can I do to display a PDF using Xamarin.Forms.
I have no problem spending $$$ on a component, but there doesn't seem to be one that works with Xamarin.Forms. The webview doesn't seem to be a good way either. I need a quick and easy way to display either PDF or DOC file in some sort of a view for Xamarin.Forms and yes, I'm willing to pay for this.
Problem is, I haven't found anything. Most of the components for PDF's deal with creating them, which I do not need or viewing them in some outside app which will not work for me.
Any help is appreciated.
Thanks
Jeff.
Web service for Xamarin.Forms app
the question is taken off
What is the easiest way to know which API method was introduced in which API level?
I found this link that nicely describes everything about these Android versions and how they work with Xamairn. In the document it says:
"If you select a Minimum Android version that is lower than your Target Framework setting, some APIs may not be available to your app at runtime. However, your app can still run on an earlier device, but with reduced functionality. For each API that is not available on Android platforms corresponding to your Minimum Android version setting, your code must explicitly check the value of the Android.OS.Build.VERSION.SdkInt property to determine the API level of the platform the app is running on.
For example, let's suppose that we want to use the NotificationBuilder.SetCategory method to categorize a notification when running on Android 5.0 Lollipop (and later), but we still want our app to run on earlier versions of Android such as Android 4.1 Jelly Bean (where SetCategory is not available). Referring to the Android version table at the beginning of this guide, we see that the build version code for Android 5.0 Lollipop is Android.OS.BuildVersionCodes.Lollipop. To support older versions of Android where SetCategory is not available, our code can detect the API level at runtime and conditionally call SetCategory only when the API level is greater than or equal to the Lollipop build version code:
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
{
builder.SetCategory(Notification.CategoryEmail);
}
"
This is a huge issue because if the developer forgets to put the check the application will not run properly on earlier platforms. So I tried this myself, so I set the Target Framework to 5.0 and the Minimum Android version to 4.1 to see if I get a warning that indicates that this method is only available on Android 5.0 and higher but unfortunately, I didn’t get any warning. I'm using Visual Studio 2017 Enterpise edition.
So my question is do the developers have to know by heart what API method was introduced in what API level and put the check? Doesn't that make the development significantly difficult?
in xamarin forms android project is unavailable
in xamarin forms android project is unavailable...while trying to reload it showing install messing features... what to do??
TokBox OpenTok SDK for Xamarin Forms.
Hi,
I have made proof of concept app for a video chat application in Xamarin Native using the below nuget packages (it works like a charm the source code is done by provider available here https://github.com/DreamTeamMobile/Xamarin.Opentok.Samples/tree/code-improvements)
https://www.nuget.org/packages/Xamarin.OpenTok.Android/
https://www.nuget.org/packages/Xamarin.OpenTok.iOS/
These nuget packages are basically a port of the native iOS/Android SDK's by TokBox for Xamarin, Created by DreamTeamMobile. I want to make use of them to for creating a Xamarin Forms application, I need some guidance how I can make the same functionality available to a Forms Project, considering that the package provider doesn't provides Xamarin Forms implementation. Would custom renderers help here.
Xamarin forms and prism and IEventAggregator instance from model class
How do i get access to the IEventAggregator from a class?
using AssetofThings.Events;
using Prism.Events;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
namespace AssetofThings.Models
{
public class DeviceInfo : INotifyPropertyChanged
{
IEventAggregator ea;
public DeviceInfo()
{
App.Current.
ea = Container.Resolve<IEventAggregator>();//****** ERROR..doesnt work
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
DeviceInfo.Current.aTimer.Interval = 5000;
DeviceInfo.Current.aTimer.Enabled = true;
}
private void OnTimedEvent(object sender, ElapsedEventArgs e)
{
ea.GetEvent<RequestGeoUpdateEvent>().Publish("RequestGeoUpdateEvent");//*******WANT TO publish an event
}
// Singleton
public static DeviceInfo Current = new DeviceInfo();
public System.Timers.Timer aTimer = new System.Timers.Timer();
private int _updateseconds=60;
public int updateseconds //seconds
{
get
{
return _updateseconds;
}
set
{
if (value != updateseconds)
{
_updateseconds = value;
OnPropertyChanged("updateseconds");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged == null)
return;
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
FlexLayout not working
Im trying to use FlexLayout but it keeps giving me this error:
(1,1): error: Position 8:14. Type FlexLayout not found in xmlns http://xamarin.com/schemas/2014/forms
Knob Control
Is there any control available like image, except the below URL
https://github.com/corneliu-serediuc/Xamarin.Forms.KnobControl... i cant able to find some feature in this control.
Please help me to identify this.
Gesture not updating its status as completed
I have a PanGestureRecognizer in my custom view. For the PanUpdated event handler, I have a function that does some stuff when the gesture is running and then something else when the gesture is completed. However, sometimes the gesture never gets to its completed state.
Any ideas?
Here's what I have...
class ImageContainer : ContentView
{
public ImageContainer()
{
PanGestureRecognizer panGesture = new PanGestureRecognizer();
panGesture.PanUpdated += OnPanUpdated;
GestureRecognizers.Add(panGesture);
}
void OnPanUpdated(object sender, PanUpdatedEventArgs e)
{
switch(e.StatusType)
{
case GestureStatus.Started:
// do some stuff
break;
case GestureStatus.Running:
// do more stuff
break;
case GestureStatus.Completed:
// sometimes this does not get called!
break;
}
}
}
Application.Resources StaticResource not found for key
Hi,
I am trying to define a Style for a custom control I have created in the Application.Resources section of my App.xaml.cs file. However the page that references this file raises an exception (StaticResource not found for key).
The sample here :-
https://github.com/xamarin/xamarin-forms-samples
Doesn't use a Key or a Custom Control for it's Application.Resources so I am not exactly sure how to get this working.
Is there any more comprehensive examples available or any pointers as to how to get this working?
Update: The same Style defined in the Page's Resources section, works successfully.
Thanks
Paul Diston
How to invoke the Async method inside that same Async method at certain condition - Xamarin Forms
My code:
private async Task ExecuteSubmissionCommand()
{
bool isImagesUploaded = UploadCapturedImages(dataAccess, AssessmentPageViewModel.maximumQueueId);
if (!isImagesUploaded)
{
isSubmissionRetry = await Application.Current?.MainPage?.DisplayAlert("Error", "Problom while uploading captured images. Do you want to retry?", "Retry", "Cancel");
if(isSubmissionRetry)
{
await ExecuteSubmissionCommand();
}
}
}
When image upload process fails due to some network connection, then I will be showing alert to the user for "Retry" option.
If user clicks retry, then I should call the same method again to upload the failed images.
Any idea guys...?
Very urgent..
Thank you so much for your hearty reply in advance.
Best practice MVVM navigation using Master Detail page?
Hi to all.
I want to follow the MVVM pattern as much as possible, but I don't know if I am doing the navigation quite well. Note that I am using a MasterDetail page and I want to maintain the Master page, changing only the Detail side when I navigate.
Here is the way I navigate from my ViewModel. In this example, from ViewModelOne to ViewModelTwo:
public class ViewModelOne : ViewModelBase
{
private void GoToViewTwo()
{
var viewTwo = new ViewTwo(new ViewModelTwo());
((MasterView)Application.Current.MainPage).NavigateToPage(viewTwo);
}
}
MasterView implementation:
public class MasterView : MasterDetailPage
{
public void NavigateToPage(Page page)
{
Detail = new NavigationPage(page);
IsPresented = false;
}
}
ViewTwo implementation:
public partial class ViewTwo : PageBase
{
public MenuView(ViewModelTwo vm)
: base(vm)
{
InitializeComponent();
}
}
PageBase implementation:
public class PageBase : ContentPage
{
public PageBase(ViewModelBase vmb)
{
this.BindingContext = vmb;
}
}
Is this the best approach (and best performance) for do the navigation? When I do some navigations, the app starts to run slower and maybe there is something I am not doing fine.
Is this the best approach for do the navigation showing always a MasterDetail page?
Thanks.
ItemsSource is null while using viewmodel with async - NotifyTaskCompletion
I am trying to have a Syncfusion Kanban UI element get populated from items from a viewmodel that gets data from an Azure database via async. The page loads with an empty Kanban (which is fine), but I wrapped my viewmodel collection ("Cards") in NotifyTaskCompletion , with the intention to have the page update once the data is loaded. However no data is ever updated; it looks like my items source is remaining null despite having it in xaml (Binding Cards.Result) and in the .cs for the view (kanban.ItemsSource = viewmodel.Cards.Result;). What am I doing wrong?
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nito.AsyncEx;
using Syncfusion.SfKanban.XForms;
using UXDivers.Artina.Grial.Helpers;
using UXDivers.Artina.Grial.Models;
namespace UXDivers.Artina.Grial.ViewModel
{
public class ClientDashboardViewModel
{
static Teacher _Teacher;
private static string user_email;
public static List Clients { get; set; }
public NotifyTaskCompletion<ObservableCollection> Cards { get; private set; }
public ClientDashboardViewModel()
{
user_email = App.User.email;
Cards = new NotifyTaskCompletion<ObservableCollection<KanbanModel>>(PopulateParams());
}
public static async Task<ObservableCollection<KanbanModel>> PopulateParams()
{
var _Cards = new ObservableCollection<KanbanModel>();
ClientMatches = new List<Match>();
Clients= new List<Case>();
List<Teacher> foundTeachers = await App.DatabaseService.GetTable<Teacher>().ToListAsync();
_Teacher = foundTeachers.Find(x => x.email == user_email);
Clients =
await App.DatabaseService.GetTable<Case>()
.Where(x => x.Teacherid == _Teacher.id)
.ToListAsync() ;
int id = 1;
foreach (var _obj in Clients)
{
List<Client> clients =
await App.DatabaseService.GetTable<Client>()
.Where(x => x.id.ToString() == _obj.Teacherid.ToString())
.ToListAsync();
Client _client = clients.FirstOrDefault();
KanbanModel model = new KanbanModel()
{
ID = id,
Title = _obj.title,
ImageURL = "logo.png",
Category = "Objects",
Description = _obj.description,
ColorKey = "Red",
Tags = new string[] {_obj.startdate, _obj.cityoccurred,}
};
_Cards.Add(model);
id++;
}
return _Cards;
}
}
}
<?xml version="1.0" encoding="UTF-8"?><StackLayout x:Name="MainLayout" >
<xForms:SfKanban x:Name="kanban" AutoGenerateColumns="False" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" ItemsSource="{Binding Cards.Result}">
<xForms:SfKanban.Columns>
<xForms:KanbanColumn x:Name="objectcolumn" Title="Objects" MinimumLimit="5" MaximumLimit="15" >
</xForms:KanbanColumn>
</xForms:SfKanban.Columns>
</xForms:SfKanban>
</StackLayout>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Syncfusion.SfKanban.XForms;
using UXDivers.Artina.Grial.Helpers;
using UXDivers.Artina.Grial.ViewModel;
using UXDivers.Artina.Grial.Views.Dashboards;
using Xamarin.Forms;
namespace UXDivers.Artina.Grial.Views.Client
{
public partial class ObjectsPage : ContentPage
{
private string client_email;
ClientDashboardViewModel viewmodel= new ClientDashboardViewModel();
protected override void OnAppearing()
{
viewmodel = new ClientDashboardViewModel();
kanban.BindingContext = viewmodel;
casecolumn.Categories = new List() { "Objects" };
KanbanPlaceholderStyle style = new KanbanPlaceholderStyle();
style.SelectedBackgroundColor = Color.FromRgb(250.0f / 255.0f, 199.0f / 255.0f, 173.0f / 255.0f);
kanban.PlaceholderStyle = style;
var test = kanban.ItemsSource;
}
public ObjectsPage(string email)
{
InitializeComponent();
kanban.BindingContext = viewmodel;
if(viewmodel.Cards.Result!=null)
kanban.ItemsSource = viewmodel.Cards.Result.ToList();
casecolumn.Categories = new List<object>() { "Objects" };
KanbanPlaceholderStyle style = new KanbanPlaceholderStyle();
style.SelectedBackgroundColor = Color.FromRgb(250.0f / 255.0f, 199.0f / 255.0f, 173.0f / 255.0f);
kanban.PlaceholderStyle = style;
client_email = email;
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nito.AsyncEx;
namespace UXDivers.Artina.Grial.Helpers
{
public sealed class NotifyTaskCompletion<TResult> : INotifyPropertyChanged
{
public NotifyTaskCompletion(Task<TResult> task)
{
Task = task;
if (!task.IsCompleted)
{
var _ = WatchTaskAsync(task);
}
}
private async Task WatchTaskAsync(Task task)
{
try
{
await task;
}
catch
{
}
var state = task.AsyncState;
var propertyChanged = PropertyChanged;
if (propertyChanged == null)
return;
propertyChanged(this, new PropertyChangedEventArgs("Status"));
propertyChanged(this, new PropertyChangedEventArgs("IsCompleted"));
propertyChanged(this, new PropertyChangedEventArgs("IsNotCompleted"));
if (task.IsCanceled)
{
propertyChanged(this, new PropertyChangedEventArgs("IsCanceled"));
}
else if (task.IsFaulted)
{
propertyChanged(this, new PropertyChangedEventArgs("IsFaulted"));
propertyChanged(this, new PropertyChangedEventArgs("Exception"));
propertyChanged(this,
new PropertyChangedEventArgs("InnerException"));
propertyChanged(this, new PropertyChangedEventArgs("ErrorMessage"));
}
else
{
propertyChanged(this,
new PropertyChangedEventArgs("IsSuccessfullyCompleted"));
propertyChanged(this, new PropertyChangedEventArgs("Result"));
}
}
public Task<TResult> Task { get; private set; }
public TResult Result
{
get
{
return (Task.Status == TaskStatus.RanToCompletion) ?
Task.Result : default(TResult);
}
}
public TaskStatus Status { get { return Task.Status; } }
public bool IsCompleted { get { return Task.IsCompleted; } }
public bool IsNotCompleted { get { return !Task.IsCompleted; } }
public bool IsSuccessfullyCompleted
{
get
{
return Task.Status ==
TaskStatus.RanToCompletion;
}
}
public bool IsCanceled { get { return Task.IsCanceled; } }
public bool IsFaulted { get { return Task.IsFaulted; } }
public AggregateException Exception { get { return Task.Exception; } }
public Exception InnerException
{
get
{
return (Exception == null) ?
null : Exception.InnerException;
}
}
public string ErrorMessage
{
get
{
return (InnerException == null) ?
null : InnerException.Message;
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
ERROR mView == null
I debug my app and Exception is not active, my not crash, and i see application onpute and one line sendUserActionEvent() mView == null, how fix ?
how to reach Item when switch toggled inside Listview
I want to store item name(c_name) when toggle the switch on this row name but i can't do this anybody help me....
<StackLayout IsVisible="False" x:Name="ShortCatagory" BackgroundColor="White" HeightRequest="100"
WidthRequest="160" Margin="5,5">
<ListView x:Name="onCategory"
RowHeight="40">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal" Padding="2">
<Switch VerticalOptions="EndAndExpand"
HorizontalOptions="EndAndExpand"
x:Name="{Binding c_name}"
Toggled="BestDis"
IsToggled="{Binding .}"
Scale=".60"/>
<Label Text="{Binding c_name}"/>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
async private void onCatagory(object sender, EventArgs args)
{
this.IsBusy = true;
try
{
string link = "product-category";
var data = new Services.DataSource();
var getData = await data.DataWithoutToken(link);
var view = JsonConvert.DeserializeObject<ObservableCollection<CategoryModel>>(getData);
onCategory.ItemsSource = view;
this.IsBusy = false;
}
catch (Exception ex)
{
await DisplayAlert("Error", ex.Message, "Close");
}
ShortCatagory.IsVisible = true;
}
Xamarin Forms 3 RTL on iOS Master detail
Hello ,
Xamarin Forms 3 RTL on iOS , When trying to navigate through Master-detail page the navigation bar icons and flow are normal LTR although FlowDirection property is RTL & even it works on Android as expected