hi! one my page1 i have a method public void UpdateDomain(string personId, IDbService databaseService) { .................. }
i would like from my page 2 to call this method when i click a button ToolbarItems.Add(new ToolbarItem("Save", null, () => { ................ }));
How to call a method from another page!?
Firebase Cloud Messaging iOS Configure() error.
I am working on adding Firebase Cloud Messaging to a Xamarin iOS project. I am using the following guide, https://components.xamarin.com/gettingstarted/firebaseioscloudmessaging. I started with a blank Xamarin forms project and began following the directions in the mentioned link.
I am getting an error when I add App.Configure (); to the FinishedLaunching method in my AppDelagate class. The error states that "app does not contain a definition for Configure ". Does anyone have any idea why I am getting this error? Is there a better guide to use for implementing FCM? Should the Configure function already be there or is that something that I need to create?
Best setup for a speedy debug cycle, when developing with Xamarin Forms
What is the best target to use in terms of having a quick debug cycle. I.e. time to edit the code, run and test. I understand some platforms and emulators are slower than others, and whilst I am building a prototype I would like to use the quickest platform to do the most debugging/testing with.
For example if I am developing an application using Xamarin Forms to target (iOS, Android and Windows Phone), which target is the quickest prototyping, debugging and testing? Assuming that I would be using Visual Studio on Windows, and have a separate Mac for doing the iOS builds and testing.
Any thoughts and considerations greatly appreciated.
Buttons in ListView DataTemplate's seem buggy / only generate under certain conditions.
Either a bug or I'm missing something in the ListView documentation.
The issue as I would describe it, is Button objects inside a ListView DataTemplate do not generate unless one of these two conditions are met:
- It is the only object.
- It has a property bound to the item.
I'd write this off as intended and think no further of it, except it seems only buttons appear to have this issue. I can mix bound and unbound labels, they all generate. Here's a stripped down example demonstrating the issue:
<ListView itemSource="{Binding SomeExampleCollection}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout>
<Label Text="{Binding SomeStringProperty}" />
<Label Text="THIS APPEARS"/>
<Button WidthRequest="100" HeightRequest="40" Text="{Binding SomeStringProperty}"></Button>
<Label Text="THIS NEXT BUTTON WILL NOT APPEAR"/>
<Button WidthRequest="100" HeightRequest="40" Text="THIS DOES NOT APPEAR"></Button>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Should be obvious (just look at the example xmal) what I'm saying doesn't work. However, this DOES work:
<ListView itemSource="{Binding SomeExampleCollection}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout>
<Button WidthRequest="100" HeightRequest="40" Text="THIS DOES APPEAR"></Button>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Copying files to emulator file system
I have a requirement to reference a sqlite database in a Xamarin Forms application. I'm using Xamarin Studio and I have an android emulator set up and working with a simple test application. When I load Android Device Monitor and click on the File Explorer tab I see an empty file system as I would expect but the pull/push file options are both disabled. Can someone explain how I can copy a file from the mac file system to the emulator? I'm very new to Xamarin development and the mac so please keep it simple!
Thanks
An exception was thrown from the 'Received' event handler. System.FormatException: Messages over 2GB
I have a .Net Core SignalR server and UWP application that successfully pushes a JSON formatted string to an UWP client.
I have in the same solution, using the same .dll as the UWP application a Xamarin Forms app. It has the SignalR Xamarin Forms Nuget package installed. The UWP and Xamarin app both consume a .Net Standard 2 .dll that handles all of the interaction with the SignalR server. I am using SignalR for .Net Core 2 alpha final release.
The UWP app works perfectly, but when I make exactly the same call with exactly the same parameters, the SignalR client-side code in the Xamarin App throws an internal exception:
`An exception was thrown from the 'Received' event handler. System.FormatException: Messages over 2GB in size are not supported`
The message I am pushing up to the client app is simply a string "Connected"
`await Clients.Client(Context.ConnectionId).InvokeAsync(LiveStreamActions.UpdateConnectionStatus.ToString(), "Connected");`
This same message, when it arrives at the UWP client is handled without issue. In the Xamarin Forms Android app, it throws the exception noted above.
Here is the code in the receiving side:
HubConnection.On<string>(LiveStreamActions.UpdateConnectionStatus.ToString(), data =>
{
Debug.WriteLine($"Received: {data}");
MessagingCenter.Send<HavenHubClient, string>(this, MessageTypes.UI_UpdateSignalRStatus.ToString(), data);
});
This code is in a .Net Standard .dll that is used by both the UWP and Xamarin apps, so it is absolutely identical. The Xamarin app has the .Net Core 2 SignalR Nuget package installed. For now, I have only worked on the Android version of the app. I will eventually implement in iOS as well.
I can supply the full error stack if it helps. I didn't include it in this message because of its size.
Does anyone have any ideas?
Why when I create a second custom renderer for android the Views changes and I loose the listeners
when I create a second custom renderer for android the event listeners (IOntouch and IOndrag) of the previous listener stop working,
Note. the first renderer is
first custom renderer
class DraggableImageRenderer : ImageRenderer, Android.Views.View.IOnTouchListener, Android.Views.View.IOnDragListener
second:
public class ReplaceableList : ListViewRenderer, Android.Views.View.IOnTouchListener
(listen for touch image (from listview in the left) and handle the Ondrag listener for the listview (right side) to perform drop. every thing works fine but when I add another custom renderer for the right side (on the listview where i drop images) the first custom renderer dont work . and the second works.
in presence of the second renderer when I loop check on all the views from the first renderer i find that the views are not the same ;
Is it possible to have multiple custom renders applied to one control?
Hey all,
I wonder I can't debug my second custom render that I have applied to the Editor view of Android. They are written in seperate classes, but it seems that applying two renders on the same control makes one not trigger at all.
Do I need to combine them to apply it for both?
Thanks in advance,
Luuk
To access Microsoft sql server 2014 database using Web API(web services) using xamarin.
I am using Windows 10 Professional with visual studio community edition 2017 ,Microsoft sql server 2014 to access database using Web API(web services) using xamarin cross plateform app. I using tutorials of Houssem Dellai on topic "Login to asp.net identity on xamarin forms". My application projects build successfully but when I am inserting data for registration and try insert it into database table I cought System.Net.HttpExecption . Application break and no comapitble code issue.
How to create Live stream app like Bigo, Facebook Live?
How to create Live stream app like Bigo, Facebook Live in Xamarin.Form
How to draw polyline on Map using coordinate?
Hi everybody!
I have a
Table SeriesOfPoint
{
string PointName,
double Longtitude,
double Latitude
}
1. How to use Polyline to show all point on Map or you have another idea please suggest me?
2. How to get FirstPoint, LastPoint?
Thank you!
Please give me a SQLite simple sample?
Hi everybody!
I'm new guy in Xamarin.Forms, I have see sample about Local Database on Xamarin websitehttps://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/databases/
But it's really hard to understand for me?
Could you please give me a simple sample about SQLite in Xamarin.Forms!
Thank you!
Images not binding/showing in xamarin.forms listview
Hi, I thought this would be easy to implement but I am just running around in circles. I've got the image picker working to select an image from the photo library. Now I was trying to display the images in a ListView. My ViewModel has an ObservableCollection called Attachements
The ImageData object is made up of just 2 properties. One is a string and the other is an ImageSource. Do I set it as an Image instead of an ImageSource? As I bind to the ImageSource property in my listview below
`
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Padding="0,5,0,0">
<Frame HasShadow="False"
BackgroundColor="{StaticResource Accent}"
VerticalOptions="Fill"
Grid.Row="0" />
<Image HeightRequest="100"
WidthRequest="100"
Aspect="AspectFit"
HorizontalOptions="Fill"
VerticalOptions="Fill"
Grid.ColumnSpan="2"
Source="{Binding ImageSourceData}">
</Image>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
`
I would expect to see an image, but nothing is showing up. I know I have an image as I put an image above the listview to make sure it was coming through as a stream alright. Just want to check that my ListView is correct and that I am using the correct property to bind to in my ImageData object. Any ideas? Cheers.
Xamarin UWP and Google Analytics
I am looking how to implement Google Analytics with Xamarin.UWP project specifically. After spending some time researching I find that Google Analytics now requires you to use Firebase, but Firebase supports only Android, iOS, and Web but not UWP.
I have found two Nugget packages that seem to support this:
UWP.SDKforGoogleAnalytics
ksemenenko.GoogleAnalytics
Has anyone implemented these with Xamarin.UWP projects successfully? Which one would you recommend?
Pie Charts & Graphs
I need to create an app which contains some pie charts. I'd like to do this using Xamarin Forms. Does anyone have any suggestions for cross platform libraries that will handle this. Thanks
How do you download an image and then set it as the icon in the toolbar?
So I read some posts and see that to set the icon in the tool bar you would use code this line:
NavigationPage.SetTitleIcon(this, "home.png");
provided that home.png is in the resource folder for the platform that you are developing for. What I am trying to do is download an
image as a byte array and save it the phone, and then provide the file as a FileSource Image, since that is what NavigationPage.SetTitleIcon takes. I have tried this so far:
public string DisplayIcon(string filename, Stream image)
{
var documentsPath = global::Android.OS.Environment.GetExternalStoragePublicDirectory(global::Android.OS.Environment.DirectoryDownloads);
var filePath = Path.Combine(documentsPath.Path, filename);
using (System.IO.FileStream output = new System.IO.FileStream(filePath, FileMode.Create))
{
image.CopyTo(output);
}
Android.Net.Uri iconPath = Android.Net.Uri.FromFile(new Java.IO.File(filePath));
return (string)iconPath;
}
I have checked the downloads folder on my phone to see if the image does get downloaded correctly and can be viewed, and it can, so that is not the problem. I have tried setting the icon in the PCL using this:
string iconSource = DependencyService.Get<ISaveAndLoad>().DisplayIcon("login.png", str);
NavigationPage.SetTitleIcon(this, iconSource);
Note: login.png is the file that I am going to create on my phone, and str is the downloaded image byte array that I converted into a memoryStream
However, I get this error:
Could not load image named: {0}: file:///storage/emulated/0/Download/login.png
I think that the problem is that the file has to be saved in the phones resources folder, to be accessed as a FileSource Image, so I was wondering if anyone knows how to save an image to the resources folder for android and ios, so that I can access it as a FileSource Image. Or if you have another way of downloading an image as a byte array and then displaying that image as the Icon in the toolbar, that would be great. Some sample code or examples would be greatly appreciated.
Thanks
Best Way to create Xamarin Forms UI Controls and Pages as Library to reuse in multiple applications
Hello,
I am rather new to Xamarin and have been developing cross-platform apps using ionic before. We are going to start a project with xamarin and so wanted to know the best way to have a library of components, pages etc so that we can reuse them in forthcoming applications as well.
I have read about sharing code within the same application using Xamarin forms and using .net standard library but I am more interested in knowing how to create a library of components to use. These components can be Xamarin Forms control or pages. This library need not have any native specific UI logic. Just xamarin forms UI should be fine for now.
What have I tried so far
I have created a xamarin forms project and converted the PCL to .NET Standard Library. This solution contains Android, ios projects. So in this project, I want to use some page created in the common library.
I tried creating a new solution with .Net Standard Library project which has Xamarin.Forms nuget package and created a xaml page "LoginPage" in this project. I packaged this project as .nuget package added it as a reference to the other solution. I got a whole list of errors with some saying that I had circular dependency.
So I am wondering if this the correct way to do it and what am i doing wrong? Is there any resource which can help me with this problem?
BindingContextChanged OldValue NewValue
Summary
When BindingContext changed, allow intercept old and new value.
API Changes
public class BindablePropertyChangedEventArgs
{
public object NewValue {get; Internal sets; }
public object OldValue {get; Internal sets; }
public BindableProperty Property {get; Internal sets; }
}
public event EventHandler <BindablePropertyChangedEventArgs> BindingContextChanged;
and use like this:
bindableObject.BindingContextChanged+= (s,e)=>
{
var oldValue = e.OldValue as INotifyPropertyChanged;
var newValue = e.NewValue as INotifyPropertyChanged;
if ( oldValue != null)
{
oldValue.PropertyChanged -= onPropertyChangedHandler;
}
if ( newValue != null)
{
newValue.PropertyChanged += onPropertyChangedHandler;
}
}
How can I have cross platform navigation similar to the Reddit app?
I'm attaching an image to show what exactly I mean. Basically when I started developing apps as a hobby about a year ago I started with xcode/swift as I use iOS but then having an interest in the first app I made I wanted to put it on Android so then figured out Android Studio but have gotten pretty sick of maintaining both and adding every new feature twice etc so would like to learn and switch to Xamarin Forms. The problem is XF has an option for TabbedPage which puts tabs at the bottom for iOS and a sliding style tab at the top for Android even though Android for awhile has supported tabs at the bottom fine. I would also like to have a secondary navigation as a tab up the top, again, image attached to explain what I'm after.
Not at all looking to be spoon fed, any pointing in the right direction would be much appreciated, example code of a basic version of what I'm after would be awesome to toy with, but of course isn't expected! Thanks!
Nevermind as I'm new I can't post images, if you open the reddit app you'll know what I mean, its the same across both iOS and Android and many apps do similar, so please don't throw "its not guidelines!" at me as I've seen that in a lot of threads I've found from googling and it just isn't helpful.
Picker shows Title instead of SelectedItem
Hy,
i can´t figure out whether this is the normal behaviour of a picker that it is not showing the SelectedItem or SelectedIndex.
My goal is to build an edit form. My object is already configured and i want to change its properties.
so i have a picker inside a grid
My CategoryList ist a List and the Category class has only a Name property for simplicity by now.
private List _categories;
public List CategoryList
{
get { return _categories; }
set { SetProperty(ref _categories, value.OrderBy(item => item.Name).ToList()); }
}
The SelectedCategory is a property in my ViewModel and the ViewModel implements the INotifyPropertyChanged interface.
private int _selectedCategory;
public int SelectedCategory
{
get { return _selectedCategory; }
set { SetProperty(ref _selectedCategory, value); }
}
I´m playing around with that since a day and all changes i´ve made did not lead to success. So is this behaviour by default or is there something i´m doing wrong?
(I´m using XF 2.5 with PRISM on .NET Standard 2.0 with the current stable release of visual studio for windows)
Thanks for any replies