I have made simple navigation pages.. Now i want to add icon for android in navigation bar.. i am new to xamarin forms.. I can't understand.. Please tell me how to do it? I added an screenshot and highlighted with black circle where i want to add an icon...
How to add an icon in navigation bar for navigation page?
Source for learning MVVM Architecture
I would like build xamarin forms application using MVVM Architecture . Can any one provide me a best source to learn mvvm architecture to build xamarin forms mobile application.
Project requires the following components installed on your machine: Xamarin.GooglePlayServices.Base
I am developing a cross platform mobile app with Xamarin Forms PCL. There I want to create a screen with Google Map, for that have added NuGet package i.e. Xamarin.Forms.Maps as guided in https://developer.xamarin.com/guides/xamarin-forms/user-interface/map/. But after installing this package, my solution stopped working and event I can't clean/rebuild it. Below is detailed error log:
Project 'WorkingWithMaps.Android' requires the following components installed on your machine:
Xamarin.GooglePlayServices.Base
JavaLibraryReference: https://dl-ssl.google.com/android/repository/google_m2repository_r24.zip-m2repository/com/google/android/gms/play-services-base/8.4.0/play-services-base-8.4.0.aar-8.4.0
AndroidResources: https://dl-ssl.google.com/android/repository/google_m2repository_r24.zip-m2repository/com/google/android/gms/play-services-base/8.4.0/play-services-base-8.4.0.aar-8.4.0
Xamarin.GooglePlayServices.Maps
JavaLibraryReference: https://dl-ssl.google.com/android/repository/google_m2repository_r24.zip-m2repository/com/google/android/gms/play-services-maps/8.4.0/play-services-maps-8.4.0.aar-8.4.0
AndroidResources: https://dl-ssl.google.com/android/repository/google_m2repository_r24.zip-m2repository/com/google/android/gms/play-services-maps/8.4.0/play-services-maps-8.4.0.aar-8.4.0Please double-click here to install it.
Intallation Errors: XA5209 Unzipping failed. Please download 'https://dl-ssl.google.com/android/repository/google_m2repository_r24.zip:m2repository/com/google/android/gms/play-services-base/8.4.0/play-services-base-8.4.0.aar' and extract it to the 'C:\Users\XYZ\AppData\Local\Xamarin\Xamarin.GooglePlayServices.Base\8.4.0\embedded' directory
XA5209 Reason: The process cannot access the file 'C:\Users\XYZ\AppData\Local\Xamarin\Xamarin.GooglePlayServices.Base\8.4.0\embedded\res\drawable-xxhdpi' because it is being used by another process.
XA5207 Please install package: 'GPS Base' available in SDK installer. Java library file 'C:\Users\XYZ\AppData\Local\Xamarin\Xamarin.GooglePlayServices.Base\8.4.0\content\classes.jar' doesn't exist.
XA5207 Please install package: 'GPS Maps' available in SDK installer. Java library file 'C:\Users\XYZ\AppData\Local\Xamarin\Xamarin.GooglePlayServices.Maps\8.4.0\content\classes.jar' doesn't exist.
Any suggestion would be great help for me.
How to track the location of mobile in xamarin.forms without internet or without GPS
i want to track the location of the mobile but GPS should not be on or internet should not be on..is it possible to track the location..
How to set two way binding for Image control in Xamarin.Forms?
Hello,
I have a custom view MyPhotoView
with Image. I have set image on load. Now I want to change image on continue button click. I have tried to use TwoWay Binding and set value of Binding property but image doesn't change on the click of Continue
button.
XAML:
<local:MyPhotoView x:Name="MyPhotoView"
OriginalImage="{Binding OriginalImage}"
CropTopLeftX="{Binding CropTopLeftX}"
CropTopLeftY="{Binding CropTopLeftY}"
CropWidth="{Binding CropWidth}"
CropHeight="{Binding CropHeight}" />
<Button Clicked="ContinueClicked" Text="Continue" FontSize="17" Command="{Binding ContinueCommand}" />
Custom Control MyPhotoView
that used in XAML
public class MyPhotoView : View
{
public static readonly BindableProperty CropTopLeftXProperty =
BindableProperty.Create(nameof(CropTopLeftX), typeof (float), typeof (MyPhotoView), 0f, BindingMode.TwoWay);
public static readonly BindableProperty CropTopLeftYProperty =
BindableProperty.Create(nameof(CropTopLeftY), typeof (float), typeof (MyPhotoView), 0f, BindingMode.TwoWay);
public static readonly BindableProperty CropWidthProperty =
BindableProperty.Create(nameof(CropWidth), typeof (float), typeof (MyPhotoView), 0f, BindingMode.TwoWay);
public static readonly BindableProperty CropHeightProperty =
BindableProperty.Create(nameof(CropHeight), typeof (float), typeof (MyPhotoView), 0f, BindingMode.TwoWay);
public static readonly BindableProperty OriginalImageProperty =
BindableProperty.Create(nameof(OriginalImage), typeof (Image), typeof (MyPhotoView),null,BindingMode.TwoWay);
public float CropTopLeftX
{
get { return (float) GetValue(CropTopLeftXProperty); }
set { SetValue(CropTopLeftXProperty, value); }
}
public float CropTopLeftY
{
get { return (float) GetValue(CropTopLeftYProperty); }
set { SetValue(CropTopLeftYProperty, value); }
}
public float CropWidth
{
get { return (float) GetValue(CropWidthProperty); }
set { SetValue(CropWidthProperty, value); }
}
public float CropHeight
{
get { return (float) GetValue(CropHeightProperty); }
set { SetValue(CropHeightProperty, value); }
}
public Image OriginalImage
{
get { return (Image) GetValue(OriginalImageProperty); }
set { SetValue(OriginalImageProperty, value); }
}
}
ViewModel
public CropPhotoViewModel(List<Image> images)
{
ContinueCommand = new RelayCommand(async () => await ContinueCommandExecute());
_images = images;
OriginalImage = images[0];
}
public Image OriginalImage { get; set; }
public List<Image> _images { get; set; }
public float CropTopLeftX { get; set; }
public float CropTopLeftY { get; set; }
public float CropWidth { get; set; }
public float CropHeight { get; set; }
public int CurrentImageCounter { get; set; }
private async Task ContinueCommandExecute()
{
//crop the image
if(CurrentImageCounter == _images.Count)
return;
else
{
var croppedImage = _cropImageService.CropImageWithRect(_images[CurrentImageCounter],
new Rectangle(CropTopLeftX, CropTopLeftY, CropWidth, CropHeight));
CurrentImageCounter++;
//I want to change image here but it doesn't change even it is 2 way binding
OriginalImage = _images[CurrentImageCounter];
//I also want to set all 4 parameter of CropTopLeftX/Y/Width/Heigh here
}
}
I have set next image to OriginalImage
property on click Continue
button but it doen't change. I also want to set all 4 parameter of CropTopLeftX/Y/Width/Heigh
Can anybody please guide me?
How can I customize the back button software action in Xamarin.Forms?
Im using Prims.Unity.Forms with Xamarin.Forms
Abandoning Xamarin.Forms :(
Hi there,
over the last months I wrote a quite big business application using forms.
The main target was UWP, but we needed the possibility to create IOS and Android versions along the road.
Overall my impressions were not too good. The goal was that just a few developers could maintain all targets.
In the end most of my time was spend working around bugs in forms and making it behave like I wanted it to.
The backend is a very portable assortment of PCL modules, around a forms host app that should provide the UI
for it, manage navigation and stuff like that. A bad design decision was that, because we had a unified design language,
that modules can provide designs for UI elements, pages and so on directly in Forms code or xaml.
It almost worked, as long as the app was simple, just a few modules providing elements for a dashboard, some process
pages. As it got more complex and flexible (updating, inserting and deleting Elements in real time, lots of more different
Elements from other modules for the dashboard) it began lacking.
What was once very smooth is now flickering and delaying.
But the real problems are, now that the app is almost finished:
Every Update somehow breaks something, most of the time the android build needs a day of reading and fixing and manually fixing
the project files to maybe work againCreating custom renderers for everything. I want a different Titlebar design for Master/Detail pages or a Frame that inexplicably
doesn't show the rounded border non-transparent or lots of other tweaks I had to research and write one. I even had to write one
that does a nasty hack for tabbed pages because for whatever reason the tab titles are non formatted or highlighted when using
it like I should. Also lack of PDF and other very default formats is lacking and needs a custom implementation. I only did this for UWP...I don't even
want to think about repeating it for Android or IOSImage problems. Using URI Sources just doesn't work sometimes. Images don't show in one place but the same URI shows
in another. I also had lots of problems when using buffered images and stream sources. For example, they don't show up when used
in datatemplates in lists, if this datatemplate is defined in a different PCL for whatever reasonRandom complete UI blocks. I made sure that there is nothing interesting running on the UI thread. And it works most
of the time just fine. Just randomly blocking UI for about 5-10 seconds. I never found a source for that.Random complete app crashes. The app works fine, concurrency should be good. But repeating the exact same process
just sometimes results in a uncatched exception with just the text "Unspecified Error" an no further explanation or stack trace
Just the random untraceable crashes are enough to never being able to release it and I'm not confident in posting bug reports for
every little thing i encountered, seeing that bugs from 2 years ago are not yet fixed and the activity on forms is severely lacking in
the last months.
Well, in the end I guess it is my fault. Forms was not the correct target for this application and luckily 90% of the code is reusable.
Sorry for the rant
Xamarin.Auth SDK doesn't persist data after closing the app - ios
I have built an application through Xamarin.Forms, I am using xamarin.auth sdk - you can find it here " https://developer.xamarin.com/recipes/cross-platform/xamarin-forms/general/store-credentials/ " - to save sensitive (login) data on each platform, Android app works correctly, I login to the app, save the data, close the app, re-open it and the data still there, but in ios every time I open the app I need to login, and after that I close it and re-open it again I need to login again (lose the data), I am debugging on a real iPhone 7 plus device, any help please?
TelephonyManager returns mobile number null
Hello Everyone,
I am trying to get the mobile number of the app installed, but getting "" instead of mobile number,
Please help me out.
My code
TelephonyManager mgr = Application.Context.GetSystemService(Context.TelephonyService) as TelephonyManager;
string OperatorName= mgr.NetworkOperatorName;
string mobilenumber = mgr.Line1Number;
Permissions i have
Facebook account kit component
I would need to use facebook account kit. Someone can you indicate how you can integrate this library?
Thank you
ToolbarItem Effect for custom font
I am attempting to create an effect that will style the ToolbarItem and give it a custom font. My breakpoint hits the PCL code, but it never seems to venture into the OnAttached()
override. I am wondering if there is something that I am missing. Do I have the ability to effect the actual styling on Navigation ToolbarItems?
iOS Effect Code
[assembly:ResolutionGroupName ("Core")]
[assembly:ExportEffect (typeof(ToolbarItemEffect), "ToolbarItemEffect")]
namespace Core.iOS.Effects
{
public class ToolbarItemEffect : PlatformEffect
{
protected override void OnAttached()
{
var style = new UIStringAttributes
{
Font = UIFont.FromName("FontName", 24)
};
var navigationBar = (UINavigationBar) Control;
navigationBar.TitleTextAttributes = style;
}
protected override void OnDetached()
{
}
}
}
Shared Code
public class ToolbarItemEffect : RoutingEffect
{
public ToolbarItemEffect() : base("Core.ToolbarItemEffect")
{
}
}
Xaml on Navigation Page
<ContentPage.ToolbarItems>
<ToolbarItem Text="Text" Command="{Binding TextCommand}">
<ToolbarItem.Effects>
<core:ToolbarItemEffect />
</ToolbarItem.Effects>
</ToolbarItem>-->
</ContentPage.ToolbarItems>
Is there any way to place a NavigationPage root into a ContentView?
I currently Have a navigation tab at the bottom of my application and I would like this to be static. ( I am not using a "Tabbed Page").
My current tab code works as so:
void Schedule_Tapped(object sender, System.EventArgs e)
{
var page = new Schedule();
PlaceHolder.Content = page.Content;
}
void Messages_Tapped(object sender, System.EventArgs e)
{
var page = new Messages();
PlaceHolder.Content = page.Content;
}
I would like to Place NavigationPage to begin the root of the ContentView so that I can push and pop to the stack.
Here is an example of what I would like to see done.
void Messages_Tapped(object sender, System.EventArgs e)
{
var page = new NavigationPage(new Messages());
PlaceHolder.Content = page.Content;
}
I Understand that I am unable to convert from type View to NavigationPage but is there a good way to approach this problem?
Thank you.
Xamarin forms iOS crashes due to signing issue
Xamarin forms iOS crashes due to signing issue
I'm having problems deploying my Xamarin forms apps to iOS. Sometimes it works sometimes it doesn't. The following code signature missing error (or similar) seems to always be the problem.
If I rebuild, then it will work, but if I rename the solution FOLDER, it will crash again.
If I make a copy of the entire folder with my solution in it and run it without changes it will crash.
Sometimes it will just hang with the "white" splash screen.
The simulators and android always works.
This is happening with not just one project.
My iOS swift projects do no have this problem. I am using the same developer account.
I tried changing the build instruction set from arm64 to something else. I've tried simplifying the code.
=====
Launched application 'com.mycompany.aaa’ on ‘my iPhone' with pid 677
dyld: Library not loaded: rpath / libmonosgen-2.0.dylib
Referenced from: aaa.iOS.app / aaa.iOS
Reason: no suitable image found. Did find:
aaa.iOS.app / libmonosgen-2.0.dylib: required code signature missing for 'aaa.iOS.app / libmonosgen-2.0.dylib'
Application 'com.mycompany.aaa' terminated.
====
My development environment is thus:
=== Visual Studio Community 2017 for Mac ===
Version 7.4.2 (build 12)
Installation UUID: 53fcefff-1737-4a8d-9526-5f7eb9f7363b
Runtime:
Mono 5.8.1.0 (2017-10/6bf3922f3fd) (64-bit)
GTK+ 2.24.23 (Raleigh theme)
Package version: 508010000
=== NuGet ===
Version: 4.3.1.4445
=== .NET Core ===
Runtime Versions:
2.0.5
2.0.3
SDK Versions:
2.1.4
2.0.3
=== Xamarin.Profiler ===
Version: 1.6.1
=== Xamarin.Android ===
Version: 8.2.0.16 (Visual Studio Community)
Android SDK:
Supported Android versions:
2.3 (API level 10)
5.0 (API level 21)
7.1 (API level 25)
8.0 (API level 26)
8.1 (API level 27)
SDK Tools Version: 26.1.1
SDK Platform Tools Version: 27.0.1
SDK Build Tools Version: 27.0.3
Java SDK: /usr
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
Android Designer EPL code available here:
xamarin / AndroidDesigner.EPL
=== Xamarin Inspector ===
Version: 1.4.0
Hash: b3f92f9
Branch: master
Build date: Fri, 19 Jan 2018 22:00:34 GMT
Client compatibility: 1
=== Apple Developer Tools ===
Xcode 9.3 (14154)
Build 9E145
=== Xamarin.Mac ===
Version: 4.2.1.28 (Visual Studio Community)
=== Xamarin.iOS ===
Version: 11.9.1.24 (Visual Studio Community)
Hash: f62de472
Branch: xcode9.3
Build date: 2018-03-29 19:30:53-0400
=== Build Information ===
Release ID: 704020012
Git revision: 0d8e3f0a4d683771f17959739956fa09c7ba21e3
Build date: 2018-03-30 10:45:17-04
Xamarin addins: 958839ea56ab1e331caf7c92b6ad50fb9e6ee9d2
Build lane: monodevelop-lion-d15-6
=== Operating System ===
Mac OS X 10.13.4
Darwin 17.5.0 Darwin Kernel Version 17.5.0
Mon Mar 5 22:24:32 PST 2018
root:xnu-4570.51.1~1 / RELEASE_X86_64 x86_64
=== Enabled user installed addins ===
Internet of Things (IoT) development (Preview) 7.1
how to integrated the complex css website in xamarin.form?
Hi, we had one web application build with complex CSS & business logic layer in Asp.net. Now as per requirement we want to build mobile application for same website using existing CSS & class file. The site is already mobile responsive, but we want to create hybrid mobile application with native look and feel. Hence we are looking for solution in xamarin cross platform.
How to check Image.Source doesn't contains URI or Stream?
I have List of 3 Images of type Xamarin.Forms.Image. First image has URI as source, Second image has stream that as I have uploaded second image from Gallery and I don't have anything in 3rd image.
List<Image> Photos = new List<Image>();
Image URIImage=ImageSource.FromURI("https://xxx.amazonaws.com/profiles/ddddd-1658-4cf1-b62c-cccccccc_1.jpg");
Photos.Add(URIImage);
Photos.Add(await GetImageFromGallery()); //"/Users/text/Library/Developer/CoreSimulator/Devices/3C26B8DD-1E37-47A0-B164-810AE3EA4A4D/data/Containers/Data/Application/05BE5988-4F9F-4E17-BCC2-xxxxxxxx/Documents/IMG_0001.JPG"
Photos.Add(new Image());
Now I want to go through loop and want to get image from Photos
that doesn't have source. Here it's 3rd image of Photos
list.
Can anybody please help me?
MVVMCross for Xamarin Native Development
I am planning to start a new project in Xamarin Native (IOS & Android) and wanted to implement MVVM pattern into it. I have read articles and blogs and found multiple recommendations to use MVVMCross and also got to know that it has very less documentation available for APIs and supported native controls related to its usage. I have also observed same for it and also found very less articles & tutorials which could help build enterprise app using MVVMCross.
Can someone redirect me to other good MVVM technology which has excellent documentation or help me find good articles or document for MVVMCross native controls (which property to use for data binding & which property to bind with commands) and support for different navigation methods like Navigation Drawer, Bottom Navigation Bar and other etc for both platforms
Note: Raising this questions on Forms blog as it has higher visibility.
Problem reliably giving focus to a picker from a button click handler on iOS.
I have a button on a form in a PCL-based iOS app which when clicked should display a pre-populated picker by giving it focus from the button click handler. It works sometimes but not always, is there a reason for this? I've used the same technique to display a datepicker and it works 100% of the time so I'm wondering why the picker is hit and miss? A forum search revealed a couple of related questions but not an answer/solution that was confirmed as working. Can anyone explain why I'm seeing this issue and/or offer a solution? Thanks.
Xamarin.Forms.AppLinks no longer working correctly after upgrade
I was running Xamarin.Forms 2.4.0.282 and Xamarin.Forms.AppLinks 2.4.0.282 using Visual Studio 2015 Enterprise and Xamarin.Android 7.1.0.43. AppLinks were working just fine. My target was Android 7.1.
I upgraded to Visual Studio 2017 Enterprise and Xamarin.Android 8.2.0.16 (HEAD/a78295902). I also upgraded to Xamarin.Forms.AppLinks to 2.5.0.280555 and Xamarin.Forms 2.5.1.444934. My target is now Android 8.1. I also tried 7.1 and 8.0.
I've noticed that none of the new registered links are appearing in the Google Search bar. One of my old links is appearing in Google Search, but when I click on it, it pulls up the web page instead of Deep Linking into my app. Here is my code.
var url = $"http://portal.domainname.com/Offers/Details/{offerId}";
_appLink = new AppLinkEntry
{
AppLinkUri = new Uri(url, UriKind.RelativeOrAbsolute),
Thumbnail = ImageSource.FromFile("icon.png"),
Description = this.offerDescription.Text,
Title = this.offerName.Text,
IsLinkActive = true
};
Application.Current.AppLinks.RegisterLink(_appLink);
/// Remove link if offer is expired
if (dateCheck)
{
Application.Current.AppLinks.DeregisterLink(_appLink);
}
Here is my assetlinks.json.
[{
"relation": "delegate_permission/common.handle_all_urls",
"target": {
"namespace": "AppName.Droid",
"package_name": "com.domainname.appname",
"sha256_cert_fingerprints": "MySha256Cert"
}
}]
Anyone else seeing this behavior? Thanks!
How to change Android default style (colors)
Hi,
I have a Xamarin.Forms with only an Android Project. I was trying to change the default Android style but unfortunatelly without success.
I want to change the Listview color for select, focus and press events, which is orange.
I am using Visual Studio 2017 (15.5.4 version) and I can´t find a tutorial to do that in this version... I have found many tutorials to do that on a native Android project, which is not taking effect.
I have did that:
- created a xml file with a selector, like that:
<?xml version="1.0" encoding="utf-8" ?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:color="#FF000000" /> <item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:color="#FF000000" /> </selector>
- changed the style.xml file, including a new style tag like that:
``
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#2196F3</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#1976D2</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#2196F3</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
<item name="android:listViewStyle">@style/ListViewStyle.Light</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#FF4081</item>
</style>
** <style name="ListViewStyle.Light" parent="android:style/Widget.ListView">
<!--<item name="background">@color/list_row_default_bg</item>-->
<item name="android:divider">@color/divider</item>
<item name="android:dividerHeight">2dp</item>
<!--<item name="android:listSelector">@color/list_row_selected_bg</item>-->
<item name="background">@drawable/item_background_selector</item>
</style>**
</resources>
included attributes in the Listview control:
<ListView ItemsSource="{Binding FaturasCollection}" RowHeight="150" HeightRequest="{Binding GridHeight}" **BackgroundColor="Transparent"**>
downloaded styles from https://www.materialpalette.com/ trying to override default style, but nothing happens.
So, my question is: Which is the correct path to do that ? I really saw so many informations, about how to do that, in so many places in the code, using or xml files, or android manifest xml file, or in .cs file, or creating xml with selectors etc but no one had the expected effect.
Please, anyone could help me ?
I need a step by step teaching how to change all Android default colors, to be able to run my app at any Android versions, with the same style, especially the ListView events colors (onselect, onpressed, onfocused).
Thanks.
Different ScrollView display behavior between iOS and Android
I'm seeing totally different behavior with my scroll view on iOS vs. Android. On iOS the behavior is correct, and what I see is all 20 of my items added to the scroll view. I can scroll to the end of the view and everything is looking good. Here's what that looks like:
On Android, however, it's completely wrong. I can only see about 9 elements before it looks really messed up. I can scroll a bit, but it stops prematurely at around the 9th element. Here's what the wrong display looks like:
Look at the bottom: things are overlapping each other and you don't see anything beyond the 9th element before it all gets jumbled. This behavior happens regardless of the simulator type and I've tried it with my Samsung S9 real phone. The code is the same between the two platforms. What could possibly account for the substantial difference between the two platforms with the same code?