There doesn't seem to be any easy way to change the textview's for DatePicker/TimePicker. Has anyone found a way to either turn a label into a datepicker or write a custom renderer that will customize the look of the datepicker. In particular I care about Android first and foremost.
DatePicker FontSize, etc.
Accessing Phone contacts and send sms
What's the best way to access the phonebook and send sms to a contact on Xamarin.Forms. Is there any good package or plugin fro Xamarin.Forms I can use to accomplish this task? Keep in mind I want it to be cross-platform. Thank you in advance for the replies.
Trouble with Binding Can get but can't set
Hi guys,
I am new to XF and just trying to learn Binding a bit.
In my XAML, I have the following label:
<Label HorizontalOptions="Center" VerticalOptions="Center" Grid.Column="0" Grid.ColumnSpan="3" Text="{Binding Credit}" />
and in the code behind, I have the following:
private string credit { get; set; }
public string Credit {
get
{
return credit;
}
set
{
credit = value;
}
}
So when I set an initial value, for example, credit = "0.00" it works perfectly fine but my problem is setting it:
private void Button_OnClicked(object sender, EventArgs e)
{
var crdString = Credit;
float crd = float.Parse(crdString);
crd++;
credit = crd.ToString();
}
But it does not update the UI.
P.S I have also set the BindingContext :
InitializeComponent ();
BindingContext = this;
App Center equivalent for Insights.Identify
Hello,
I'm working on changing a Xamarin.Forms app to use Microsoft App Center with the impending retirement of Xamarin Insights. So far it seems to be going well, though I do have a question about it.
In the app currently, we were using Insights.Identify to provide additional helpful information to us when looking at the Insights logs, such as the name of the user that has logged in, and the system that they're connecting to. I've been trying to find the equivalent for this in Microsoft App Center, but I didn't find anything in any of the documentation of the APIs that I was reviewing, and there doesn't seem to be any methods provided in the App Center NuGet packages that handle this same functionality.
Is this feature not implemented in App Center yet or is there some other way to provide this information in App Center? I tried creating a CustomProperties object, setting some Key/Value pairs in the object, and then calling AppCenter.SetCustomProperties, but that didn't seem to help. Would the best option right now be to just pass an IDictionary object with the key/value pairs I want to include in the log when making calls to methods like Crashes.TrackError or Analytics.TrackEvent?
Thanks in advance!
xam.plugin.media not working on Android (Works on UWP)
xam.plugin.media not working on Android (Works on UWP)
I've started xamarin forms recently and have been trying to get xam.plugin.media to work. I scoured the web and am at the end of my wisdom.
I'm checking if I have permissions, a camera is available, photo is supported and even then it crashes.
Plugins were implemented as stated by the readme and/or fellowbloggers.
Permissions set in my xamarin liveplayer device.
Even tried example solutions but since they are usually out of date and xamarin aswell as the plugin doesnt quite like that they didnt work aswell.
Solution github.com/peyter213/xam_plugin_media-Issue
Thanks to anyone that dares to take a look.
Error: i.imgur.com/GrarxPq.png
Codeexample of the MainPage
MainPage.xaml.cs
` private async void Btn_takePhoto_Clicked(object sender, EventArgs e)
{
try
{
var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Camera);
if (status != PermissionStatus.Granted)
{
if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Camera))
{
await DisplayAlert("Camera Permission", "Allow SavR to access your camera", "OK");
}
var results = await CrossPermissions.Current.RequestPermissionsAsync(new[] { Permission.Camera });
status = results[Permission.Camera];
}
if (status == PermissionStatus.Granted)
{
await CrossMedia.Current.Initialize();
if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
{
await DisplayAlert("No Camera", ":( No camera available.", "OK");
return;
}
var s = CrossMedia.Current.IsCameraAvailable;
var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
{
PhotoSize = PhotoSize.Medium,
});
if (file == null)
return;
}
else if (status != PermissionStatus.Unknown)
{
await DisplayAlert("Camera Denied", "Can not continue, try again.", "OK");
}
}
catch (Exception ex)
{
await DisplayAlert("Error", "Camera Not Available", "OK");
}
}`
How to use ClassId
Hi,
I'm trying to do an alternative ListView where I want to be able to change and update labels after the "cells" are created. This is my first test, just put alot of stacklayouts in a scrollview. The problem is that I cant figure out how to change the ".Text" parameter for the labels based on their ClassIds.
This simple test should work as that if I click on for example the button with the ClassId "1" the Text of the Label with the ClassId "lbl1" should change to "Hello". So I guess the main question is how to reference an item based on it's ClassId? Hope this makes some sense..
Best regards
Magnus
using System;
using Xamarin.Forms;
namespace TestScroll2
{
public partial class TestScroll2Page : ContentPage
{
StackLayout mainLayout;
public TestScroll2Page()
{
mainLayout = new StackLayout
{
Margin = new Thickness(0, 0, 0, 0)
};
for (var i = 0; i < 40; i++)
{
var stackLayout = new StackLayout();
stackLayout.ClassId = "Stack" + i;
var stackLabel = new Label()
{
Text = "Separators in stack layout " + i
};
stackLabel.ClassId = "lbl"+i;
var stackButton = new Button()
{
Text="Click Me"
};
stackButton.ClassId=""+i;
stackButton.Clicked += OnButtonClicked;
stackLayout.Children.Add(stackLabel);
stackLayout.Children.Add(stackButton);
stackLayout.BackgroundColor = Color.Gray.MultiplyAlpha(0.2);
mainLayout.Children.Add(stackLayout);
}
Content = new ScrollView() {
Margin = new Thickness(0, 30, 0, 0),
Content = mainLayout
};
}
void OnButtonClicked(object sender, EventArgs e)
{
Button btn = (Button)sender;
StackLayout stl = (StackLayout)btn.Parent;
DisplayAlert("Alert", "OnButtonClicked: "+btn.Parent.ClassId , "OK"); // this works
//this.FindByName<Label>("lbl1").Text="Hello"; -> this is where I like to update the corresponding label
}
}
}
missing templates in visual studio
hi,
i have visual studio enterprise 2017 and i installed all the things to be worked with xamarin.
i did it maybe 5 times in two weeks and im getting crazy.
when i choose in visual studio file->new->project, i choose in the left pannel for c#, cross platform
i have only two options:
1)UI Test APP
2)class library(xamarin forms)
everyone i know include posts at the internet have a third option:
3)Cross platform App(xamarin forms or native)
which is the exactly i need!
when i choose the second option i can choose between shared project or .net standard. this thing its only in my computer
everyone else has portable class instead of the .net standard option and i need the poratable!
what do i need to install to have the third options?
i've been trying to seek for this two weeks
please help!!!
PushModalAsync() new window is hidden under previous window
Xamarin forms on Android.
I'm using PushModalAsync() to open a new window. Most of the time it works fine, but occasionally the new window is created but is not visible, as if it's hidden behind the previous page. The OnAppearing() event for the new page is triggered. If I tap the menu button on my tablet to bring up the list of open applications, then tap on my application to return focus to my app, then suddenly the new window pops into view. Is there a way to force the new window to pop to the top, or force a screen redraw of some kind after PushModalAsync()? This is how I'm opening the new window:
public void OpenMyNewWindow(void)
{
try
{
if (myNewPage == null)
myNewPage = new MyNewPageType();
Navigation.PushModalAsync(myNewPage);
}
catch (Exception e)
{
// handle errors...
}
}
How to enable log option in android and ios devices using xamarin.forms app
In my cross-platform Xamarin Forms application I would like to have a Logging option. If it's enabled, it should generate a log file stating the errors or in which step the app is crashing (if any of these takes places while the app is running) and I should be able to pull and check this generated log file.
When I googled for this I found on many sites that we need to debug using usb and check it on android adb, but once the application goes live and user downloads it in their phone if app crashes any time then the user should be able to turn on the logging button and once the process is run it generates a log file. The user can then send the file to the developer to check what exactly is happening in the system.
How do I implement this feature in Xamarin Forms for both iPhone and Android?
Unable to display the downloaded PDF in webview
I am facing issue in displaying the downloaded pdf in webview of xamarin android
code i am using for getting the path for downloading
public string GetLocalFilePath(string filename)
{
// string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);
var documentsPath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads);
string filepath= Path.Combine(documentsPath.Path, filename);
return filepath;
}
usimg dependency injection for tracking the path
var data = App.Locator.DependencyService.Get().GetLocalFilePath("Hello.pdf");
File Operation to get the file
FileInfo filepath = new FileInfo(data);
var filestorage = filepath.Directory.GetFiles();
Binding the path to webview in xaml(pcl)
var data = App.Locator.DependencyService.Get().GetLocalFilePath("Hello.pdf");
webview.Source=data;
i am unable to display pdf in webview for xamarin android,help me with this issue
WebView on Xamarin.Forms is not loading the files from the application local storage
Hi,
I am developing a application on using Xamarin.forms for the cross platforms (UWP,iOS and Android). I am able to download the file from server and able to store to local storage using PCLStorage cross platform plugin.
I am trying to create a viewer using the WebVIew which will display the local storage files as per each platform support.
I am using WebView to create the viewer so that this can be used on each platform. When loading the files from local storage webview is not loading the files even not showing any error in loading. I am facing this issue on the UWP platform.
I am following the URL schema ms-appdata:///local/ for loading the local storage files as per
E.g:_
ms-appdata:///local/Packages/8126d6e9-f697-4abd-924b-73a159412c15_4fh6xh3q1xw62/roaming/1-17045247-1.PDF
Please help me to resolve this issue.
Thanks & Regards,
Alok Pandey
Data Template for CarouselView throws error of DataTemplate returned non-view content in Xamarin.For
I want to create DataTemplate for CarouselView where I can set ActivityIndicator before the image gets loaded. I have tried by following way but it throws an error. Can anybody please suggest me?
I am getting this error: System.InvalidOperationException: DataTemplate returned non-view content: 'TestPro.CacheImageCell'.
I have tried a lot to put my code here but it looks like something is wrong with this editor. It doesn't show my xaml code in question. So, I have put my code in Stack Over Flow.
Here is the link: Question
Text in grouped Listview Slides out of grid when scrolling for sometime before adjusting back
Am showing a list of fuel prices and fuel types grouped on based on fuel stations. However, when I scroll the list, the label at the start slides out of the row for a moment and only comes back to original position if the page is left by without any interaction for some time.
The behavior is completely random meaning some labels might shift one time and some other at another. Also, this only happens with the first label inside the ListView ItemTemplate.
Attaching screenshot for better clarity.
below is the code for the listView
<ListView ItemsSource="{Binding ListOfFuel}" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,.5,1,0.8" IsGroupingEnabled="True" SeparatorVisibility="None" HasUnevenRows="True" >
<ListView.GroupHeaderTemplate >
<DataTemplate >
<ViewCell Height="60">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="10*"/>
<RowDefinition Height="90*"/>
</Grid.RowDefinitions>
<Label Text="" Grid.Row="0" BackgroundColor="{StaticResource PageBackgroundColor}" />
<Frame Style="{StaticResource FrameStyle}" Grid.Row="1" Margin="10,0,10,0" Padding="20,4,20,4">
<Grid x:Name="FuelSationInfo">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="75*"/>
<ColumnDefinition Width="25*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Label Style="{StaticResource ListLabel}" Text="{Binding Name}" FontSize="{StaticResource MediumFontSize}" />
<Button Style="{StaticResource ButtonStyle}" Grid.Column="1" IsEnabled="{Binding MapEnabled}" Text="Map" FontSize="{StaticResource SmallFontSize}" Command="{Binding Source={x:Reference fuelStationsDetail}, Path=BindingContext.NavigateToStation}" CommandParameter="{Binding Source={x:Reference FuelSationInfo}, Path=BindingContext}"/>
</Grid>
</Frame>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.GroupHeaderTemplate>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell Height="40">
<Frame Style="{StaticResource FrameStyle}" BackgroundColor="{StaticResource SecondaryColor}" Padding=" 20,5,20,0" Margin="10,-18,10,0">
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="75*"/>
<ColumnDefinition Width="25*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Grid.Row="0" Style="{StaticResource ListLabel}" Text="{Binding Type}" HorizontalTextAlignment="Center" FontSize="{StaticResource SmallFontSize}"/>
<StackLayout Orientation="Horizontal" Grid.Column="1" Grid.Row="0">
<Label Style="{StaticResource ListLabel}" Text="{Binding Price}"
HorizontalOptions="EndAndExpand" HorizontalTextAlignment="End" FontSize="{StaticResource SmallFontSize}"/>
<Label Style="{StaticResource ListLabel}" FontSize="{StaticResource XSmallFontSize}" Text="{Binding Source={x:Reference fuelStationsDetail}, Path=BindingContext.LocalCurrencySymbol}"/>
</StackLayout>
</Grid>
</Frame>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
how to add webservice reference in xamarin.forms portable project
Hi,
I'm seen the "Todo PCL" example from xamarin forms examples, and i try to add webservice reference, and can't appear the menu "add webservice reference" (Reference > right click at mouse button ), i in visual studio 2015 Update 2 portable project.
i was see the todoWCF example and its included webservice proxy setting in the portable solution.
How can i add and generate all objects related to wsdl webservice (proxy setting, etc) in the portable solution?
Regards
Javier Garcia
Getting error on Visual Studio 2017 for Xamarin.Forms iOS "Native linking failed"
iOS build failed while debugging, but it is working fine in iPhoneSimulator
Error info :
- Error Native linking failed, undefined symbol: _AudioServicesCreateSystemSoundID. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. HelloWorld.iOS
- Error Native linking failed. Please review the build log. HelloWorld.iOS
- Error Native linking failed, undefined symbol: _AudioServicesPlaySystemSound. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in. HelloWorld.iOS
Note : I am not using any _AudioServices I dont know why this error is getting only in iPhone Device while it is working fine in iPhoneSimulator
Thank you,
Jitendra Jadav
Local Db distribution with app
Good Day, does anyone have a nice sample that shows how to distribute A sqlite DB Together with a Xamarin forms app (PCL).
I would need an Android , UWP, and IOS implementation of the file helper that picks up an existing DB file.
Thanks in advance
Xamarin forms master detail page has few issues in Xamarin Mac.
- Master detail page Menu icon is not getting displayed at all ( irrespective of having the icon in both resources as well as in image sets ).
- Screen flickers for every navigation that happens through the click of the option
I have tried several options, but nothing seems to sort this out. Any help would be greatly appreciated.
Xamarin Forms Version : 2.5
Toolbar title set center align.
how can i title will be set center align in toolbar using Android layout.
How to setup payment with debit card on xamarin forms?
I have a POS application build with Xamarin.Forms, inside xamarin forms how to setup payment with debit card?
Use a boolean to switch between two ObservableCollections in a ListView
Hello everyone
I have a boolean ("ShowChildrenDocumentsSetting") in a "SettingsViewModel" that I want to use to change the items source of a Listview.
The binding context of this Listview is a ViewModel with two ObservableCollections ("Documents" and "AllDocuments").
How can I change dynamically the ItemsSourceProperty of my Listview using this boolean to switch between those collections?
I tried using Datatrigger in my view's constructor but I didn't manage to make it work:
DataTrigger dataTriggerTrue = new DataTrigger(typeof(ListView))
{
Value = "True",
Binding = new Binding("ShowChildrenDocumentsSetting") { Source = Helper.SettingsViewModel }
};
Setter sourceSetterTrue = new Setter()
{
Property = ListView.ItemsSourceProperty,
Value = new Binding("AllDocuments") { Source = this.BindingContext}
};
dataTriggerTrue.Setters.Add(sourceSetterTrue);
listView.Triggers.Add(dataTriggerTrue);
DataTrigger dataTriggerFalse = new DataTrigger(typeof(ListView))
{
Value = "False",
Binding = new Binding("ShowChildrenDocumentsSetting") { Source = Helper.SettingsViewModel }
};
Setter sourceSetterFalse = new Setter()
{
Property = ListView.ItemsSourceProperty,
Value = new Binding("Documents") { Source = this.BindingContext }
};
dataTriggerFalse.Setters.Add(sourceSetterFalse);
listView.Triggers.Add(dataTriggerFalse);
Right now I'm doing it like this (see code below) in my view's constructor but it's not dynamic.
I need to recreate the page to see the change in the Listview's collection if I change the ShowChildrenDocuments value :
if (Helper.SettingsViewModel.ShowChildrenDocuments) {
listView.SetBinding(ListView.ItemsSourceProperty, "AllDocuments");
} else {
listView.SetBinding(ListView.ItemsSourceProperty, "Documents");
}
Any idea on how this should be done ?
Thank you in advance !