Hi all
I made an app for home cleaner request.
when map opens , user see his location on map and every thing is ok.
Now I want show a pin on center of map and user can change map position manually and I get its location(pin on center of map) .
How can I do that? Please get code for that if you made this before. Thanks
(my c# code is in ViewModel)
show a pin on center of map and get its location
Datepicker, serious problems
Hi all together,
i have serious Problems with Datepicker.
ProjectWorkTimeDetailViewModel.cs
public class ProjectWorkTimeDetailViewModel
{
more code..................
public override void OnNavigatedTo(NavigationParameters parameters)
{
base.OnNavigatedTo(parameters);
if (parameters.ContainsKey("PWT"))
{
var projectWorkTime = (ProjectWorkTime)parameters["PWT"];
CurrentWorkTime = new ProjectWorkTimeEdit(projectWorkTime);
CurrentWorkTime.PropertyChanged += OnPropertyChange;
}
}
private void OnPropertyChange(object sender, PropertyChangedEventArgs e)
{
if (!Title.EndsWith("*"))
{
Title = Title + " *";
}
_canSave = true;
SaveCommand.RaiseCanExecuteChanged();
}
}
ProjectWorkTimeDetail.xaml
<ViewCell>
<StackLayout Orientation="Horizontal" Padding="13,0">
<Label Text="Arbeitstag: " VerticalOptions="Center"></Label>
<DatePicker Format="dd MMM yyyy"
Date="{Binding CurrentWorkTime.WorkDay,Mode=TwoWay}"
HorizontalOptions="FillAndExpand"></DatePicker>
</StackLayout>
</ViewCell>
ProjectWorkTimeEdit.cs
public class ProjectWorkTimeEdit : BindableBase
{
ProjectWorkTime _entity;
public ProjectWorkTimeEdit (ProjectWorkTime entity)
{
if (entity == null)
{
throw new ArgumentNullException(nameof(entity));
}
_entity = entity;
_workDay = entity.WorkDay;
_job = _entity.Job;
_workTime = _entity.WorkTime;
}
DateTime _workDay;
public DateTime WorkDay
{
get => _workDay;
set => SetProperty(ref _workDay,value);
}
........... more code
}
As you can see i'm initializing 'ProjectWorkTimeEdit.cs' and set values in the Constructor. After that, i add the 'OnPropertyChanged' EventHandler.
Directly after this Line:
CurrentWorkTime.PropertyChanged += OnPropertyChange;
I have a Event fired from
public DateTime WorkDay
{
set => SetProperty(ref _workDay,value);
}
here without doing anything
I'm shure that this problem has something todo with the Datepicker because if i commented out the Datepicker all works as expected.
Any idea???
Thanks in advance
Peter
Custom renderer for Toolbar Items not working for TabbedPage
Hi,
I have 2 toolbar items in tabbed page (with two tabs).
<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage
xmlns="site wont let me post links"
xmlns:x="hence deal with custom qualified names"
xmlns:views="clr-namespace:TestApp.Views"
x:Class="TestApp.Views.MyTabbedPage"
>
<views:Page1 Title="Page 1" />
<views:Page 2 Title="Page 2" />
</TabbedPage>
I am trying to move one toolbar item on left using custom renderer:
assembly: ExportRenderer(typeof(MyTabbedPage), typeof(TabbedPageRenderer))]
namespace TestApp.iOS
{
public class TabbedPageRenderer : TabbedRenderer
{
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
var navigationItem = this.NavigationController.TopViewController.NavigationItem;
if (navigationItem.RightBarButtonItems.Length > 1)
{
navigationItem.LeftBarButtonItems = new UIBarButtonItem[] { navigationItem.RightBarButtonItems[1] };
}
navigationItem.RightBarButtonItems = new UIBarButtonItem[] { navigationItem.RightBarButtonItems[0]};
}
}
}
it works fine when page is loaded for first time. But when I click on tab to show the Page 2, It renders both toolbar items on right again (item on left stays at left) resulting in 3 toolbar items.
Can anyone please help me with this small issue?
Cheers
How do I enable hardware acceleration when deploying to device?
I am developing a xamarin forms application right now and I have some problems with hardware acceleration.
Specifically, in the android emulator, hardware acceleration works, ie
System.Numerics.Vector.IsHardwareAccelerated
returns true.
On the device however, it returns false, and thus libraries like ImageSharp are super slow.
I already checked the build settings and "Optimize code" is checked everywhere. Also I added HardwareAccelerated = true
to the MainActivity.cs in the android project, but that doesn't change anything.
The phone I am using is the OnePlus 5, and the Android version on the phone is 8.1, on the emulator its 7.1.
Anybody can help?
Cheers, Johannes
Type StyleSheet not found in xmlns /schemas/2014/forms
I am trying to put stylesheets into my forms.
So I have:
<ContentPage.Resources>
<StyleSheet Source="/Styles/Styles.css" />
</ContentPage.Resources>
I have spent around an hour trying to resolve this. First it would not build and it took me a while to realise that my Xamarin.Forms NuGet was out of date. So I updated to the latest and compiled.
Finally it built. However now when I run it into the live player, it crashes instantly and in the debug window I have the message "error: Position 9:10. Type StyleSheet not found in xmlns /schemas/2014/forms". So it seems back to square one.
Any help is appreciated.
*Couldn't put the full link for the schema as it won't let me...
HasShadow Property of Frame not working
I am using Xamarin Forms and I am trying to build a cardview style control by putting a frame inside a listview and it doesn't look like the HasShadow property is working properly. I have it set to true but it doesn't look like there is a shadow. Right now I have only looked at it on Android.
I'm not sure if it's related or not but I'm using the ExtendedViewCell from the Labs project and the ShowSeparators property isn't working either.
Anyone have any thoughts on why this could be happening?
PushAsync() and delay
I'm wondering how to avoid delation after Navigation.PushAsync() was called. Where do I need to post all my initialization code for view and view model? At a moment my init code is in constructors of view and view model classes and my app has a delay of about half a second before push animation starts.
P.S. Using iOS
ContentPage.BindableObject.PropertyChanged
I've noticed something odd and hoping someone from Xamarin will reply. (NOTE: I understand how to subclass INotifyPropertyChanged and implement the methods so my data binding works both ways. This question is not about how to implement in that manner but whether there is some mechanism in ContentPage that already supports property change notification and what the messages I'm seeing really mean. If I don't need to re-implement something which ContentPage already does, that's a good thing.)
If I create a VM that subclasses ContentPage:
public class MainVM : ContentPage
And then attempt to add my own PropertyChangedEventHandler in that class:
public event PropertyChangedEventHandler PropertyChanged;
Xamarin informs me that my new property "hides inherited member 'BindableObject.PropertyChanged'".
This implies to me that ContentPage (or one of its ancestor classes) already implements a PropertyChangedEventHandler named PropertyChanged. I'm thinking "Great, I don't need to specifically implement the property change notification mechanism as it is handled by ContentPage." And, in fact, if I make no other changes, I can confirm that one-way binding works. Changing a value in the UI updates the property in the VM. However, two-way binding does not work -- the UI is not updated when the VM code updates the property.
Based upon the above message, I expect there would be an available BindableObject property on my VM.
If I implement a method to handle the other side of notification:
private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
{
if (this.BindableObject.PropertyChanged != null)
{
this.BindableObject.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
Xamarin informs me that my VM "does not contain a definition for 'BindableObject'" even though it is subclassing ContentPage.
So, the messages seem to be giving conflicting information: One says there is an inherited member "BindableObject.PropertyChange" while the other says there is no "BindableObject" member.
How Could We Determine Where The App Was Purchased?
I have had no problem distributing my Xamarin Forms Android apps through both Google Play Store and the Amazon store... until now.
This time I am offering a premium upgrade and the app needs to know where it was purchased from so that it can buy the premium upgrade from the correct store. Is there a way to determine, not the device nor the platform, but where the app was purchased?
I doubt I am the first one to encounter this problem, but I couldn't find a solution. Appreciate any help I can get. Thanks.
Pass token back to XamarinForms App
I have created LinkedIn Custom Auth in NodeJS on VPS.
From Xamarin Forms I call NodeJs script, which call LinkedIn authorization form and response with access token.
My question is how to pass this access token back to XamarinForms app?
I have tried to do this with WebView but I failed.
Xamarin.Forms - Triggering an IsBusy Binding
I have an IsBusy
binding that can be activated by saying bool isBusy = true; ... or false;
. However, I have realized that bool
is the only place I can set IsBusy
to be true/false.
Can I trigger my IsBusy
binding somewhere other than at bool
? I have been trying out IsBusy = true/false
everywhere and reading tutorials, I'm not sure what I'm doing differently, it does not seem to update my IsBusy
binding.
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System;
using System.ComponentModel;
using System.Windows.Input;
using Xamarin.Forms;
using Rox;
namespace PreAppStructure
{
public class RoxViewModel : INotifyPropertyChanged
{
public RoxViewModel()
{
}
// IsBusy be manually toggled with: bool isBusy = true/false;
bool isBusy;
// Can I toggle it somewhere else?
public event PropertyChangedEventHandler PropertyChanged;
public bool IsBusy
{
get { return isBusy; }
set
{
isBusy = value;
OnPropertyChanged(nameof(IsBusy));
}
}
//Property Changes
protected void OnPropertyChanged(string propertyName)
{
PropertyChangedEventArgs eventArgs = new PropertyChangedEventArgs(propertyName);
PropertyChanged?.Invoke(this, eventArgs);
}
}
}
Play Sound using Phone Speaker even when the app is closed
Hi,
I want to know how can I send a sound from a URL to the phone speaker even when the app is closed. I have seen many apps doing this so you go and select the song and then close the app but you can still listen to the song.
Kindly advise..
Thanks,
Jassim
Testing in Android - getting an error with the shared runtime
I'm trying to test my XF application in an Android genymotion emulator. Unfortunately, I can't get the application to start. I am getting the following error when I look this up in monitor. This appears to tell me that:
1. the runtime can not be found.
2. that I have somehow messed up my sdk versions in the manifest file.
09-09 14:10:15.617: A/monodroid(32097): cannot find libmonosgen-2.0.so in override_dir: /data/data/AppXForms.Droid/files/.override, app_libdir: /data/app-lib/AppXForms.Droid-1 nor in runtime_libdir as: /system/lib/libmonosgen-2.0.so
09-09 14:10:15.617: A/monodroid(32097): Do you have a shared runtime build of your app with AndroidManifest.xml android:minSdkVersion < 10 while running on a 64-bit Android 5.0 target? This combination is not supported.
09-09 14:10:15.617: A/monodroid(32097): Please either set android:minSdkVersion >= 10 or use a build without the shared runtime (like default Release configuration).
I've been running with various versions of the genymotion android emulator (4.1.1 to 5.0).
The manifest file is included below. it is fairly clean and the minimum sdk version is set to 15, which should satisfy the error above.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="AppXForms.Droid"
android:versionCode="1" android:versionName="trakref">
<uses-sdk android:minSdkVersion="15" />
<application android:icon="@drawable/icon" android:label="trakref"></application>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
For the mean time, I can get around this by not using the shared runtime, but any thoughts are appreciated. Thanks.
Wally
how to create slideup panel in xamarin.forms
Hi all
am creating xamarin forms application. i need to add slideuppanel like google maps and google play.
now i searched many website but i can't to find it. Finally find one it is DK.SlideUpPanel but it not satisfy me since it means if the user drag on half panel it slideuppanel set half of height or set draggable height
Save Dialog box
How can one display Save Dialog box like DisplayAlert, in which user will be prompted for file name with Ok, Cancel Button?
CarouselView.FormsPlugin not rendering in StackLayout
For some reason, the carousel is not rendering. I reduced this to bare minumum. I have tried this in a page with only the carousel and it works. The label above it shows, but not the carousel. Is there a problem with StackLayout and this control?
<StackLayout x:Name="List" Orientation="Vertical" IsVisible="True">
<Label Margin="10" FontSize="Large" Text="Houses found..." FontAttributes="Bold" HorizontalOptions="Center" HorizontalTextAlignment="Center"/>
<car:CarouselViewControl x:Name="propertyCarousel">
<car:CarouselViewControl.ItemTemplate>
<DataTemplate>
<Label Text="{Binding .}" FontSize="30"/>
</DataTemplate>
</car:CarouselViewControl.ItemTemplate>
</car:CarouselViewControl>
</StackLayout>
Is there a package as iCarousel in xamarin forms.
I have been trying to implement the cylindrical animation to the horizontal listview to achieve the iCarousel cylindrical effect.Here is the sample I have tried .
<ContentPage.Resources>
<ResourceDictionary>
<xamanimation:StoryBoard
x:Key="empListViewAnimation"
Target="{x:Reference empListView}">
<xamanimation:TranslateToAnimation TranslateY="90" Easing="SpringOut" Duration="800" />
</xamanimation:StoryBoard>
</ResourceDictionary>
</ContentPage.Resources>
<ContentPage.Triggers>
<EventTrigger Event="Appearing">
<xamanimation:BeginAnimation
Animation="{StaticResource empListViewAnimation}" />
</EventTrigger>
</ContentPage.Triggers>
<ContentPage.Content>
<StackLayout Spacing="0">
<!-- <xamanimation:StoryBoard x:Key="empListViewAnimation" Target="{x:Reference empListView}">
<xamanimation:TranslateToAnimation TranslateY="600" Duration="0" />
<xamanimation:TranslateToAnimation TranslateY="0" Easing="SpringOut" Duration="800" />
</xamanimation:StoryBoard>-->
<Controls:HorizontalList x:Name="empListView" ListOrientation="Horizontal" HeightRequest="300" BackgroundColor="Transparent" ItemsSource="{Binding}" Margin="10,0,10,0">
<Controls:HorizontalList.ItemTemplate>
<DataTemplate>
<templates:ServiceItemTemplate />
</DataTemplate>
</Controls:HorizontalList.ItemTemplate>
</Controls:HorizontalList>
</StackLayout>
</ContentPage.Content>
and this is the service template
<ContentView.Content>
<Grid>
<Controls:AnimatedDonutChart x:Name="DonutChart" Percentage="{Binding Percentage}" StrokeHeight="15" DefaultColor="Gray" ValueColor="Purple" WidthRequest="150" HeightRequest="200" />
</Grid>
</ContentView.Content>
Icon-76.png not found
Please help me, I am totally frustrated with xamarin iOS development, stuck to publish an app on apple store from many days.
I am using visual studio 2017 and xamarin.forms 3.0.0.
First I added the icons in resources file . Just replaced icons with same size with mine as default icons created from xamarin template.
Added all icon names in Info.plist.
CFBundleIconFiles
Icon-60@2x
Icon-60@3x
Icon-76
Icon-76@2x
Default
Default@2x
Default-568h@2x
Default-Portrait
Default-Portrait@2x
Icon-Small-40
Icon-Small-40@2x
Icon-Small-40@3x
Icon-Small
Icon-Small@2x
Icon-Small@3x
Finally application published. but in 1/2 hour received an email.
Dear Developer,
We identified one or more issues with a recent delivery for your app, "xxxxxxx". Please correct the following issues, then upload again.
Missing Info.plist value - A value for the Info.plist key 'CFBundleIconName' is missing in the bundle 'com.xxxxxxx.xxxxxxxxxxxx'. Apps built with iOS 11 or later SDK must supply app icons in an asset catalog and must also provide a value for this Info.plist key.
Best regards,
The App Store Team
I was not using AppIcon set there, not sure why they are forcing me to use that?
So I need to publish app so I choose second approach, created asset catalog and added all the required icons and iTuneWorks icons everything that they required. But now I am not able to build/run it locally. It is showing some weird error.
Error File not found: /Users/uma/Library/Caches/Xamarin/mtbs/builds/xxxxxxxxxx.iOS/Media.xcassets/AppIcon.appiconset/Icon-76.png xxxxxxxxxx.iOS
However there is no place to put this file in asset catalog but I have added this even the error is same.
Can somebody please help?
Info.Plist and contents.json attached.
Disposing ViewCells
Hi,
in my custom ViewCell I have a complex BindableProperty that also has some event handlers. In the propertyChanged and propertyChanging delegates I wire/unwire those event handlers but the unwiring does never happen, which of course leads to memory leaks.
So my idea was to wire in OnAppearing and unwire in OnDisappearing, which doesn't really help either as OnDisappearing isn't called for every cell when I navigate back for example.
What would be a good workaround, or is there anything I can override from the ViewCell that gets called when the cell is disposed? Maybe a reset of the binding context?
(I can't change my ViewModel itself, and also can't remove the event handlers).
Thanks and all the best, Roland
How can I save data locally on my Xamarin Forms?
i need to store the data locally so that it can be accessible for the next viewmodel.