Hi, new to the platform.
I see how to do the android and ios, how do I also build a website app that shares code with android and ios via Xamarin.
Thank you for answering what is probably a silly question.
Hi, new to the platform.
I see how to do the android and ios, how do I also build a website app that shares code with android and ios via Xamarin.
Thank you for answering what is probably a silly question.
I seems Xamarin.Forms don't support Mono.Android 8.0? Upgrading Android support libraries to 26.x.x (API level 26 = 8.0 Oreo) because Xamarin.forms seems to have a strict dependency to 25.x.x.
Example:
When trying to upgrade Xamarin.Android.Support.Design to 26.1.0.1 the following error occurs:
"Version conflict detected for Xamarin.Android.Support.Compat. Reference the package directly from the project to resolve this issue.
TestApp.Android -> Xamarin.Android.Support.Design 26.1.0.1 -> Xamarin.Android.Support.Compat (= 26.1.0.1)
TestApp.Android -> Xamarin.Android.Support.v4 25.4.0.2 -> Xamarin.Android.Support.Compat (= 25.4.0.2)."
And also, if you look at the dependencies for the Xamarin.Forms nuget package, MonoAndroid 8.0 isn't even listed. Why is that? And what can I do to use API level 26 support libraries in XF?
Hi,
I'm using the Xam.Plugin.Pushnotification package to implement cross platform push notification.
It works fine on the iOS build and works mostly on the Android build.
In iOS if a notification comes in, app loads and then a prompt opens offering to tell the user more information. This occurs in foreground and background, provided the app is running.
On Android, the prompt will load if the app is in the forground.
The issue I'm having is that if a push notification comes in while the app is not in the foreground (but still running in background), when the user selects the notification the app will fully relaunch.
As such it won't get the message that it's been started by the push notification and I can't show my prompt and redirect the client.
I've checked the permissions in the manifest and as far as I can tell they are all set, WakeLock is turned on etc.
Has anyone else experiences this? The behaviour I'm looking for is for the app to just take focus and the prompt to load via the OnMessage function
Michael
I did this:
<Image Source="my_image.png" Grid.Row="0" Grid.Column="0" ></Image>
when i run my app doesn't appear. I'm having many issues with to load image in my App. That image is at root of app(PCL Project). My complete code(xaml)
<ContentPage.Content>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<BoxView Color="Red" Grid.Row="0" Grid.Column="0" />
<BoxView Color="Green" Grid.Row="0" Grid.Column="1" />
<BoxView Color="Green" Grid.Row="1" Grid.Column="0" />
<BoxView Color="Green" Grid.Row="1" Grid.Column="1" />
<BoxView Color="Green" Grid.Row="2" Grid.Column="0" />
<BoxView Color="Green" Grid.Row="2" Grid.Column="1" />
<BoxView Color="Yellow" Grid.Row="3" Grid.Column="0" />
<Image Source="my_image.png" Grid.Row="0" Grid.Column="0" ></Image>
<Label Text="Desvio" Grid.Row="0" Grid.Column="0" TextColor="White" FontAttributes="Bold"/>
<Label Text="Faturamento" Grid.Row="0" Grid.Column="0" VerticalOptions="EndAndExpand" HorizontalOptions="Center" TextColor="White" FontAttributes="Bold"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ContentPage.Content>
I have started a basic tutorial on how to develop a cross platform app via azure using xamarin.forms. A few days ago, I was able to run the Droid version of the project (via emulator) and found the app there. As of a few days ago, the app is missing when I launch the android emulator. I don't know where to start to resolve this - any help would be appreciated.
I tried updating the packages that the solution uses which may have caused the problem. I had them re-installed to no avail.
i am getting one issue in my app.i am trying to retrieve my current position(Using Mvvm) and pass it to my custom renderer but when try to call below code
if (locator.IsGeolocationAvailable && locator.IsGeolocationEnabled) { CustomPinResponse objresponse = new CustomPinResponse(); var pos = await locator.GetPositionAsync(TimeSpan.FromSeconds(5), null); if (pos != null) { double lat = pos.Latitude; double lon = pos.Longitude; objresponse = await App.GoogleApiBALObject.GetPlaceUsingWord(lat, lon, "hospital"); if (objresponse.Success == true) { for (int i = 0; i < objresponse.Data.Count; i++) { ListCustomPins = new ObservableCollection<CustomPin> { objresponse.Data[i] }; } } else await App.dialogManager.ShowMessage(objresponse.ErrorMessage.ToString(), ""); } }
before retrieve my current position my uwp custom renderer call and could not get any data.
my custom renderer is as below
` protected override void OnElementChanged(ElementChangedEventArgs
if (e.OldElement != null)
{
nativeMap.MapElementClick -= OnMapElementClick;
nativeMap.Children.Clear();
mapOverlay = null;
nativeMap = null;
}
if (e.NewElement != null)
{
var formsMap = (ModifyMap)e.NewElement;
nativeMap = Control as MapControl;
customPins = formsMap.Items;
nativeMap.Children.Clear();
nativeMap.MapElementClick += OnMapElementClick;
if (customPins != null)
{
foreach (var pin in customPins)
{
var snPosition = new BasicGeoposition { Latitude = pin.Pin.Position.Latitude, Longitude = pin.Pin.Position.Longitude };
var snPoint = new Geopoint(snPosition);
var mapIcon = new MapIcon();
mapIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/pin.png"));
mapIcon.CollisionBehaviorDesired = MapElementCollisionBehavior.RemainVisible;
mapIcon.Location = snPoint;
mapIcon.NormalizedAnchorPoint = new Windows.Foundation.Point(0.5, 1.0);
nativeMap.MapElements.Add(mapIcon);
}
}
}
}`
Please help me i tried to search on google but not found any proper solution.
I need instant and single value true/false to be reflected to my sqlite when I changed the switch value.
I have ListView binding it with ViewModel . I'm new at Xarmarin maybe i missing something.
<ListView
ItemsSource="{Binding Items}"
HasUnevenRows="true"
RefreshCommand="{Binding LoadItemsCommand}"
IsPullToRefreshEnabled="true"
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
CachingStrategy="RecycleElement"
>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Padding="10">
<StackLayout Orientation="Horizontal">
<Label Text="Is Checked?" />
<Switch IsToggled="{Binding IsChecked}" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
public partial class Details : ContentPage
{
MyViewModel viewModel;
public ViewDayDetails()
{
InitializeComponent();
BindingContext = viewModel = new MyViewModel();
}
protected override void OnAppearing()
{
base.OnAppearing();
if (viewModel == null || viewModel.Items == null || viewModel.Items.Count == 0)
viewModel.LoadItemsCommand.Execute(null);
}
}
public class MyViewModel : BaseViewModel
{
public ObservableCollection<MyModel> Items { get; set; }
public Command LoadItemsCommand { get; set; }
public MyViewModel ()
{
Items = new ObservableCollection<MyModel>();
LoadItemsCommand = new Command(async () => await ExecuteLoadItemsCommand());
}
async Task ExecuteLoadItemsCommand()
{
if (IsBusy)
return;
IsBusy = true;
try
{
Items.Clear();
var items = await App.Database.GetList();
foreach (var item in items)
{
Items.Add(item);
}
IsBusy = false;
}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
finally
{
IsBusy = false;
}
}
}
I am currently trying to fix an annoying problem in my Xamarin Forms app (iOS and Android).
Assume a NavigationPage that currently has two pages on the stack:
Page2 (topmost, currently displayed)
Page1
Page2 has a Button "Go to Page3", that binds to a Command which in turn executes the following method:
Task Navigate()
{
return navigationPage.PushAsync(new Page3(), true);
}
Now what I do is the following:
I tap the "< BACK" button in the navigation bar, and then immediately tap "Go to Page3" before Page2 has a chance to disappear.
This causes Page2 to animate away and Page1 to appear. Then as soon as Page1 has appeared, the app navigates to Page3, leading to the following navigation stack:
Page3 (topmost, currently displayed)
Page1
This is more or less correct from the point of view of the NavigationPage I suppose, but I do not want my app to be able to get into this state.
I would be able to prevent this if there was a way to detect back navigation as soon as it starts, but I can't see how to detect that.
How do you solve this issue?
I get errors that undetected packages Xamarin.Android.Support.v7... 25.4.0.2. But I use Xamarin.Android.Support... 26.1.0.1 and target Android version 8.0.
Any help.
I can't find any up to date tutorials on how to implement either Firebase or Insight for Xamarin.Forms on Visual Studio. They are all discussing Android Studio to set it up for Android for example (using gradle etc.. no idea what that is). And it seems Insight has become HockeySDK now? I dont know.
I want some crash reporting for my app before I launch it. But Xamarin does not make anything easy or self-explanatory. Everything is such a hazzle with poor to no decent documentation. So please if anybody have added firebase or insight for crash reporting. Please send me the URL to the tutorial you used, for setting it up on Visual Studio. I'm currently stuck...
I'm starting to learn Xamarin, I created a project in MVVM and Prism. I would like to include a Splash Screen screen, but I have already seen several examples and none works, when it works it does not leave the screen. Does anyone have a simple example? Thank you.
So I understand how XAMLC
works and that it compiles the Xaml which means it has to do less processing at Runtime.
But does it also compile DataTemplates
as these are Created at runtime?
Is it better to use a DataTemplate
or a ContentView
when talking about XAMLC or do they both work in the same way?
Hello.
I'm starting the development of a new Xamarin.Forms app that should build dynamic forms with multiple custom input types, configured in a web application and consumed by the app using a REST service (A Google Forms-like app). Considering this requirement the data produced by the user inputs will be very dynamic, depending on the form configuration. The app should be full functional when offline too. For example, a form can have the following configuration structure:
Form 1:
Age : Integer input
Name : Text input
Active : Boolean input
Address : Group {
Street : Text input
Number : Integer input
}
An input produced by a given user considering the above "Form 1" configuration can be something like:
{
Age : 28,
Name : "Jon",
Active : true,
Address : {
Street : "Main street",
Number : 100
}
}
As you can see the result of an user input is a JSON object. Currently I'm looking for an storage solution with the following requirements:
I have took a look in a lot of alternatives, like CouchDB, Siaqodb, Realm, etc. but none of the alternatives has fit my requirements. I think that I'm looking for a kind of "MongoDB lite" to work with Xamarin.Forms. Does anyone know something like this?
Can anyone suggest me an alternative that fits these requirements or provide any guidance about how to achieve my goal?
I'd like to remove items from the ListView's ItemSource collection. It's easy to get a reference to the currently selected item. However I do not have a reference to the group containing the item. I can traverse the collection to find the group containing the item, then remove it from the group. I have a feeling there could be a better way to accomplish this. Are there any Xamarin offered solution to find the currently selected group? Or any 'better' solution than traversing the whole collection?
I'm using Sqlite in my application using Xamarin Forms .
My code works in Android and IOS project but in UWP it returning wrong result.
public Task<int> InsertProgram(Program program)
{
return database.InsertAsync(program);
}
in UWP returning Id is wrong ?
Hi Xamarin Friends Today i have to creating custom image entry but im stuck this point
i am trying to connect mobile via Bluetooth at that time i want to show indicator with message, how can i do this?
Hi,
I would like to create a stacklayout control filled with controls using C# and then wrap this stacklayout inside a ScrollView. My code is as below.
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
this.Content = this.BuildView();
}
private Layout BuildView()
{
StackLayout stackHeaderInv = new StackLayout()
{
Padding = new Thickness(0, 10),
HorizontalOptions = LayoutOptions.FillAndExpand,
BackgroundColor = "Gray" ,
};
//Custom control definition
...
Button btnComplete = new Button() { Text = "Order Complete", HorizontalOptions = LayoutOptions.Center};
btnComplete.Clicked += btnComplete_Clicked;
stackHeaderInv.Children.Add(CustomControl);
StackLayout stackAll = new StackLayout()
{
Padding = 0,
Spacing = 0,
Children =
{ stackHeaderInv, btnComplete }
};
return stackAll;
}
Now I would like to add more controls to the stacklayout and so I need to use a ScrollView to scroll this page. I would like to know how to add the ScrollView to this BuildView() method in C#. Due to some reason I am not able to create this page with XAML and so have to use C# to create the page.
Thanks.
Rajesh.
Hi,
I have very strange problem,
I have 4 Content pages, uses the same viewmodel, the process of adding new elements to the ObservableCollection is defined inside the view model,
3 of the 4 pages working perfectly and I can do "load more" and "pull to refresh" inside them,
the 4th page not working, it still blank, after debugging I found the their is an exception thrown when adding a new element to the ObservableCollection,
the exception is:
NSInternalInconsistencyException Reason: Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).
P.S: I am binding the ObservableCollection to listview item source.
P.S: again, 3 of 4 of the pages working perfectly
P.S: this problem shown after updating to latest version of Xamarin (in order to target iPhone X)
my Code is:
private async Task fillList(bool isRef = false)
{
try
{
if (articles.Count > 0)
articles.Clear();
List<Article> t = new List<Article>();
t = App.DB.getArticlesByType(articleType);
if (isRef || t == null || t.Count == 0)
{
if (articleType == 0)
t = await App.restClient.getMainArticles();
else if (articleType == 1)
t = await App.restClient.getMyListArticles();
else if (articleType == 2)
t = await App.restClient.getReadLaterArticles();
else if (articleType == 3)
t = await App.restClient.getMostReadArticles();
for (int i = 0; i < t.Count; i++)
t[i].artType = articleType;
App.DB.insertAllArticles(t);
}
headImage = t[0].Image;
headTitle = t[0].Article_title;
headCategory = t[0].Category;
headAuthor = t[0].Author;
head_is_read_later = t[0].Is_read_later == "yes" ? "yes" : "no";
headArticle = new Article()
{
Article_id = t[0].Article_id,
Article_name = t[0].Article_name,
Article_title = t[0].Article_title,
artType = articleType,
Author = t[0].Author,
Category = t[0].Category,
Content = t[0].Content,
ID = t[0].ID,
Image = t[0].Image,
Is_read_later = t[0].Is_read_later == "yes" ? "yes" : "no",
myId = -1
};
for (int j = 1 ; j < t.Count; j++)
{
t[j].myId = j + 1;
t[j].Is_read_later = (t[j].Is_read_later == null) ? "no" : t[j].Is_read_later;
this.articles.Add(t[j]); // the exception thrown in this line
}
}
catch (Exception ex)
{
//await App.Current.MainPage.DisplayAlert("خطأ", ex.Message, "موافق");
}
}
Hello
I am trying to work with Xamarin.Form. To get a overview I want to write an application that shows on all plattforms (UWP, ANDROID, iOS) a local notification.
For UWP it worked perfectly!
I am using dependency injection.
For iOS I have this Code here. And this do not work. The Notification is never shown!
There is no crash and monitoring the code with a breakpoints do not Show any problems.
public void SetGeofence(List<GeoLocation> GeofencesInformationList)
{
var locationManger = new CLLocationManager();
locationManger.RequestAlwaysAuthorization();
locationManger.RequestWhenInUseAuthorization();
if (CLLocationManager.LocationServicesEnabled)
{
if (CLLocationManager.Status != CLAuthorizationStatus.Denied)
{
if (CLLocationManager.IsMonitoringAvailable(typeof(CLCircularRegion)))
{
locationManger.DidStartMonitoringForRegion += (o, e) => {
Console.WriteLine("Now monitoring region {0}", e.Region.ToString());
showNotification("Test", "Test!");
};
locationManger.RegionLeft += (o, e) => {
Console.WriteLine("Just left " + e.Region.ToString());
};
locationManger.RegionEntered += LocationManger_RegionEntered;
foreach (var item in GeofencesInformationList)
{
locationManger.LocationsUpdated += LocationManger_LocationsUpdated;
CLCircularRegion region = new CLCircularRegion(new CLLocationCoordinate2D(item.Latitude, item.Longitude), item.radius, item.ID);
if (!locationManger.MonitoredRegions.Contains(region))
{
locationManger.StartMonitoring(region);
}
}
}
}
}
}
private void LocationManger_LocationsUpdated(object sender, CLLocationsUpdatedEventArgs e)
{
showNotification("View Alert", "Location Updated!");
}
private void LocationManger_RegionEntered(object sender, CLRegionEventArgs e)
{
Console.WriteLine("Just entered " + e.Region.ToString());
showNotification("View Alert", "Just entered");
}
private void showNotification(string Header, string Content)
{
UILocalNotification notification = new UILocalNotification();
notification.AlertTitle = "Alert Title"; // required for Apple Watch notifications
notification.FireDate = NSDate.FromTimeIntervalSinceNow(15);
notification.AlertAction = Header;
notification.AlertBody = Content;
UIApplication.SharedApplication.ScheduleLocalNotification(notification);
}
In App delegate i tried to add this Code here https://developer.xamarin.com/guides/ios/platform_features/user-notifications/deprecated/local_notifications_in_ios_walkthrough/
and also tried this
if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
{
// Ask the user for permission to get notifications on iOS 10.0+
UNUserNotificationCenter.Current.RequestAuthorization(
UNAuthorizationOptions.Alert | UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound,
(approved, error) => { });
}
else if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
{
// Ask the user for permission to get notifications on iOS 8.0+
var settings = UIUserNotificationSettings.GetSettingsForTypes(
UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
new NSSet());
UIApplication.SharedApplication.RegisterUserNotificationSettings(settings);
}
in info.plist I added this keys.
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Test</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Test1</string>
It would be awsome if someone can help me. I really want to write code in Xamarin.Forms.
I dont want to use the Plugins because i want to learn it first step by step.
Thanks
Agredo