I am using VS for Mac for Xamarin.iOS development. I do not see "View as: Generic" option to support for any screen sizes. My iOS designer allows me to design UI only for a particular device size. Enabling and disabling "AutoLayout" and "Use Size classes" does not make any difference. My Xamarin.iOS and VS for Mac is of latest version. Can somebody help me how to get generic view back ?
Thanks
↧
View as:Generic not showing in latest Xamarin.iOS Designer ?
↧
OxyPlot WPF Change tracker text color
I'm using OxyPlot in a Xamarin Froms WPF project and the tracker (popup when I click on a datapoint) is white with light yellow text, on top of a white plot background.
It's basically impossible to see.
How can I change the font color of the tracker to black?
↧
Cannot clear GridLayout in Xamarin
Hello everyone,
I'm creating a grid in xamarin form in which I'm implementing buttons using a list values that a I want to change throught a popup ( using Rg.Plugins.Popup.Services) that open when I'm Clicking on any of those buttons.
The problem is that, the list in which i'm storing my buttons values (FindGridCollectionValue) is updating correctly, but the values displayed on my buttons doesn't change when I'm validating the value on my Popup.
Here is my code (the view)
-The gird implementation:
public AssesmentGridPage()
{
_agpm = new AssesmentGridPageModel();
InitializeComponent();
BindingContext = _agpm;
_agpm.NewGridCollectionValue();
gridLayout.RowDefinitions.Add(new RowDefinition { Height = 70 });
gridLayout.RowDefinitions.Add(new RowDefinition { Height = 70 });
gridLayout.RowDefinitions.Add(new RowDefinition { Height = 70 });
gridLayout.RowDefinitions.Add(new RowDefinition { Height = 70 });
gridLayout.RowDefinitions.Add(new RowDefinition { Height = 70 });
gridLayout.RowDefinitions.Add(new RowDefinition { Height = 70 });
gridLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = 183 });
gridLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = 183 });
gridLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = 183 });
int ProductIndex = 0;
for (int rowIndex = 0; rowIndex < 6; rowIndex++)
{
for (int columnIndex = 0; columnIndex < 3; columnIndex++)
{
if (ProductIndex >= _agpm.GridCollection.Count)
{
return;
}
var grid = _agpm.GridCollection[ProductIndex];
GridButton = new Button
{
ClassId = "" + ProductIndex,
Text = grid.Name + "\r\n" + grid.Value,
BackgroundColor = Color.FromHex(grid.Color),
};
int request = grid.Value;
GridButton.Clicked += async (object o, EventArgs e) => await PopupNavigation.Instance.PushAsync(new PopupAssementGridPage(request, Convert.ToInt32(ClassId)));
gridLayout.Children.Add(GridButton, columnIndex, rowIndex);
ProductIndex += 1;
}
}
}
and my pop up page code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PolQual.ViewModels;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Rg.Plugins.Popup.Services;
using System.Text.RegularExpressions;
namespace PolQual.Views
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class PopupAssementGridPage
{
private AssesmentGridPageModel _agpm;
private int indexButton;
public static bool essai;
public AssesmentGridPageModel AGPM { get => _agpm; }
//constructeur
public PopupAssementGridPage(int request, int index)
{
_agpm = new AssesmentGridPageModel();
essai = true;
indexButton = index;
InitializeComponent();
EntryValue.Placeholder = Convert.ToString(request);
}
//bouton d'annulation
private void ReturnToOldPage(object sender, EventArgs e)
{
PopupNavigation.Instance.PopAsync(true);
}
//bouton de validation
private void ValidateValue(object sender, EventArgs e)
{
int value = Convert.ToInt32(EntryValue.Text);
_agpm.FindGridCollectionValue(value, indexButton);
PopupNavigation.Instance.PopAsync(true);
}
}
}
and my methods in the view model code :
public void FindGridCollectionValue(int ButtonValue, int ButtonIndex)
{
for (int search = 0; search < ButtonIndex+1; search++)
{
int essai = GridCollectionValue[ButtonIndex].Value = ButtonValue;
GridCollectionValue[ButtonIndex].Value = ButtonValue;
}
_agp = new AssesmentGridPage(GridCollectionValue);
}
finally, the method which is supposed to reload my grid :
public AssesmentGridPage(ObservableCollection<ViewModels.Grid> UpdateList)
{
InitializeComponent();
BindingContext = _agpm;
gridLayout.RowDefinitions.Add(new RowDefinition { Height = 70 });
gridLayout.RowDefinitions.Add(new RowDefinition { Height = 70 });
gridLayout.RowDefinitions.Add(new RowDefinition { Height = 70 });
gridLayout.RowDefinitions.Add(new RowDefinition { Height = 70 });
gridLayout.RowDefinitions.Add(new RowDefinition { Height = 70 });
gridLayout.RowDefinitions.Add(new RowDefinition { Height = 70 });
gridLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = 183 });
gridLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = 183 });
gridLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = 183 });
int ProductIndex = 0;
for (int rowIndex = 0; rowIndex < 6; rowIndex++)
{
for (int columnIndex = 0; columnIndex < 3; columnIndex++)
{
if (ProductIndex >= UpdateList.Count)
{
return;
}
var grid = UpdateList[ProductIndex];
GridButton = new Button
{
ClassId = "" + ProductIndex,
Text = grid.Name + "\r\n" + grid.Value,
BackgroundColor = Color.FromHex(grid.Color),
};
int request = grid.Value;
GridButton.Clicked += async (object o, EventArgs e) => await PopupNavigation.Instance.PushAsync(new PopupAssementGridPage(request, Convert.ToInt32(ClassId)));
gridLayout.Children.Add(GridButton, columnIndex, rowIndex);
ProductIndex += 1;
}
}
}
↧
App crash when denied location permission in Xamarin iOS
i need to have location in my app and app got crash when user denied the location permission by clicking "Don't Allow". i got "System.Reflection.TargetInvocationException". but once i again start again even on that time the permission is denied its not crashing . in android its working fine .Do i need to update permission plugin or change in info.Plist? i gave all three permission in info.Plist for Location . here is my code .
var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location);
if (status != PermissionStatus.Granted)
{
if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Location))
{
await Application.Current.MainPage.DisplayAlert("Location denied", "app needs access to location for this operation.", "OK");
}
var results = await CrossPermissions.Current.RequestPermissionsAsync(Permission.Location);
status = results[Permission.Location];
}
if (status == PermissionStatus.Granted)
{
// do something
}
else if (status != PermissionStatus.Unknown)
{
// Crash when user denied permission
}
↧
Archive for Publishing is not creating an archive
I am experiencing a recent issue where running Archive for Publishing is not creating an archive for my Xamarin.Android project (part of Xamarin.Forms project). The Xamarin.iOS project does not have this issue.
Any thoughts on what to check for with this issue? As per the archive logs, the unsigned apk file is being created in the /bin/Release output, but that is the extent of it. No errors that I see in the logs either.
↧
↧
Any ebook reader SDK for Xamarin forms?
Requirement is to create something like ebook reader app. Any suggestions on this. @JamesMontemagno
↧
Can you turn off copying text without a selection?
For me it's highly annoying that you can copy a line without having text selected. Since cmd+c and cmd+v are so close together, it's very common for me to accidentally hit cmd+c instead of cmd+v since I'm pressing cmd with the left thumb at the same time. This happens to me several times during the day:
I select and cut some code with cmd+x
I move to an empty line and accidentally hit cmd+c instead of cmd+v
...clipboard now consists of "\n" instead
I have to press cmd+z to get my code back, then start all over again.
I get depressed
↧
VS for Mac - files visible in IDE not in .csproj file
I'm probably going mad/senile but I've got a problem with my .csproj file seemingly not being updated when files are added to the project.
Some background
The background to this is that in our Xamarin.Forms project, a colleague copied/pasted and then reused a XAML page and code-behind. If you don't do it right, you get the
ListButtonControl.xaml
and
ListButtonControl.xaml.cs
files appearing next to each other in the project, rather than the xaml.cs being nested under the xaml. This also causes pages using the control not to disply - so it's not just a cosmetic IDE thing. The solution is to remove them (but not delete them) and then add a file of the same name and take the prompt to add the existing file.
The Problem
So, having done this, I noticed that no changes were flagged in SourceTree (our Git client) for the .csproj file.
Looking inside the .csproj file, there is no mention of ListButtonControl or even the folder they're contained in.
The project is a .Net Standard 2.0 library holding the cross-platform elements for a Xamarin.Forms project.
The upshot is that fixing the files in the solution is not going to get pushed to Git, because the .csproj file hasn't changed.
Am I forgetting/missing something regarding where this project metadata is stored?
Version information:
=== Visual Studio Community 2017 for Mac ===
Version 7.7.3 (build 43)
Installation UUID: 650b4c91-c7f5-4ee5-ad70-6f178f314906
GTK+ 2.24.23 (Raleigh theme)
Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)
Package version: 516000221
=== Mono Framework MDK ===
Runtime:
Mono 5.16.0.221 (2018-06/b63e5378e38) (64-bit)
Package version: 516000221
=== NuGet ===
Version: 4.8.0.5385
=== .NET Core ===
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
2.1.5
2.1.2
2.1.1
2.0.5
SDK: /usr/local/share/dotnet/sdk/2.1.403/Sdks
SDK Versions:
2.1.403
2.1.302
2.1.301
2.1.4
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/msbuild/15.0/bin/Sdks
=== Xamarin.Profiler ===
Version: 1.6.4
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler
=== Updater ===
Version: 11
=== Apple Developer Tools ===
Xcode 10.1 (14460.46)
Build 10B61
=== Xamarin.Mac ===
Version: 5.2.1.13 (Visual Studio Community)
Hash: a4332c90
Branch:
Build date: 2019-01-11 13:08:10-0500
=== Xamarin.iOS ===
Version: 12.2.1.13 (Visual Studio Community)
Hash: a4332c90
Branch: d15-9
Build date: 2019-01-11 13:08:09-0500
=== Xamarin.Android ===
Version: 9.1.5.1 (Visual Studio Community)
Android SDK: /Users/jameslavery/Library/Developer/Xamarin/android-sdk-macosx
Supported Android versions:
2.3 (API level 10)
4.0.3 (API level 15)
4.1 (API level 16)
4.3 (API level 18)
4.4 (API level 19)
5.0 (API level 21)
5.1 (API level 22)
6.0 (API level 23)
7.0 (API level 24)
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: 28.0.0
SDK Build Tools Version: 26.0.2
=== Microsoft Mobile OpenJDK ===
Java SDK: /Users/jameslavery/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.9
openjdk version "1.8.0-9"
OpenJDK Runtime Environment (build 1.8.0-9-microsoft-b00)
OpenJDK 64-Bit Server VM (build 25.71-b00, mixed mode)
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL
=== Android Device Manager ===
Version: 7.7.1.0
Hash: 06ceaea1
=== Xamarin Inspector ===
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1
=== Build Information ===
Release ID: 707030043
Git revision: 5896ab2acba037c62271742e9e56b900c96c1d8f
Build date: 2019-01-15 21:18:33+00
Build branch: release-7.7
Xamarin extensions: e5b43ba963b7b407aa5b9f2c59018c32a709e6ab
=== Operating System ===
Mac OS X 10.13.6
Darwin 17.7.0 Darwin Kernel Version 17.7.0
Fri Nov 2 20:43:16 PDT 2018
root:xnu-4570.71.17~1/RELEASE_X86_64 x86_64
=== Enabled user installed extensions ===
LiveXAML 1.3.31
MFractor 3.7.5
MvvmCross Template pack 2.0.1
NuGet Package Management Extensions 0.14
Template Creator 0.4
Redth's Addins 1.0.9
Internet of Things (IoT) development (Preview) 7.5
↧
Calling REST Service inside the fragment and populating data inside the recycle view
Hi!
I'm a beginner with Xamarin Android. I'm trying to build an app that uses a REST service to get data from the server.
I'm trying to call the web service inside a fragment which uses a recycler view to list the contents of the data. The issue is, the call to the client function is made after the recycler adapter class has been called so the data doesn't get populated.
Here's the code of my fragment class:
public override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
notifications = new List<Notification_Struct>();
mClient = new WebClient();
Url = new Uri("http://10.71.34.1:63026/api/notifications/PetePentreath");
mClient.DownloadDataAsync(Url);
mClient.DownloadDataCompleted+= MClient_DownloadDataCompleted;
// Create your fragment here
}
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
// Use this to return your custom view for this Fragment
// return inflater.Inflate(Resource.Layout.YourFragment, container, false);
View view = inflater.Inflate(Resource.Layout.recyclerviewcontainer, container, false);
notifitem = view.FindViewById<RecyclerView>(Resource.Id.rv);
notifitem.HasFixedSize = true;
layoutmanager = new LinearLayoutManager(Activity);
adapter = new NotificationAdapter(notifications);
notifitem.SetLayoutManager(layoutmanager);
notifitem.SetAdapter(adapter);
return view;
}
void MClient_DownloadDataCompleted (object sender, DownloadDataCompletedEventArgs e)
{
string json = Encoding.UTF8.GetString(e.Result);
notifications = JsonConvert.DeserializeObject<List<Notification_Struct>>(json);
}
}
I'm calling the web service inside OnCreate because calling it inside OnCreateView doesn't fire up the DownloadDataCompleted event.
I want this event to be fired before the adapter class is called so the notification variable has the data to be passed to the recycler view adapter. How do I achieve this?
Any help is appreciated.
Thanks!
↧
↧
Xamarin animation crashes app
I am developing card game in xamarin form. I
am doing animation like card moving or chip moving from one place other place sometime it works sometimes it's crashes directly. Anybody facing this sort of issue and if having solution to solve this solution. Please help me...
am doing animation like card moving or chip moving from one place other place sometime it works sometimes it's crashes directly. Anybody facing this sort of issue and if having solution to solve this solution. Please help me...
↧
Basic Deployment and Build Questions
- I create a new project (Xamarin, Blank project). I compile it. My Android phone is plugged into the computer. I start the ADB server. Then I select Deploy and I get a deployment to the Emulator. I don't want that. I want to deploy to the phone. What gives? How do I diagnose? How do I stop deployment to the emulator?
↧
Xamarin forms local database
I am trying to implement a database following this: https://docs.microsoft.com/nl-nl/xamarin/xamarin-forms/app-fundamentals/databases
But I am getting an aggregate.exception on the main() function when debugging on my iphone.
I added this to my app.cs:
`
static ItemDatabase database;
public static ItemDatabase Database
{
get
{
if (database == null)
{
database = new ItemDatabase(
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "WaarStaatSQLite.db3"));
}
return database;
}
}`
Then this is the database class:
`public class ItemDatabase
{
readonly SQLiteAsyncConnection database;
public ItemDatabase(string dbPath)
{
database = new SQLiteAsyncConnection(dbPath);
database.CreateTableAsync<Item>().Wait(); // aggregate.exception probably from this line
Debug.WriteLine("Created Database");
}
//get all items from db async
public async Task<ObservableCollection<Item>> GetItemsAsync()
{
Debug.WriteLine("get items");
var data = await database.Table<Item>().ToListAsync();
Debug.WriteLine(data.ToString());
if(data != null)
{
return new ObservableCollection<Item>(data);
}
else
{
return null;
}
}
//get all items from db not async
public async Task<ObservableCollection<Item>> GetItemsNotDoneAsync()
{
var data = await database.QueryAsync<Item>("SELECT * FROM [Item] WHERE [Done] = 0");
return new ObservableCollection<Item>(data);
}
//get item from db with id
public async Task<Item> GetItemAsync(int id)
{
return await database.Table<Item>().Where(i => i.ID == id).FirstOrDefaultAsync();
}
//save or update a single item
public async Task<int> SaveItemAsync(Item item)
{
if (item.ID != 0)
{
return await database.UpdateAsync(item);
}
else
{
return await database.InsertAsync(item);
}
}
//delete item in db
public async Task<int> DeleteItemAsync(Item item)
{
return await database.DeleteAsync(item);
}
}`
I then call this function in the MainPageViewModel:
`public override async void OnNavigatedTo(INavigationParameters parameters)
{
var data = await App.Database.GetItemsAsync();
if (data != null)
{
Debug.WriteLine(data.ToString());
Items = data;
}
}`
OnNavigatedTo is a prism function.
I first thought maybe the OnNavigatedTo function can't be async but I found a question only saying the OnNavigatedTo function could be async void.
So I did some debugging using breakpoints and print statements and I found that the code stops in the database constructor on the createTable line. Because the Debug.writeline is never executed. Using a breakpoint on that line didn't help because i couldn't step in on the function.
I don't know if I needs to implement something in the ios-project because the sample didn't include anything.
Any help implementing databases is appreciated.
↧
CLEARTEXT communication to host not permitted by network security policy
I updated my android phone to the latest OS and now I can't consume the APIs on my DEV backend that does not use https.
I only have certificates for a few domains and for my test environment i don't have one, so i've been using http.
Now of course i get the
CLEARTEXT communication to <my-subdomain.com> not permitted by network security policy
exception.
I tried adding a security_config.xml file to the android project like explained here:
https://stackoverflow.com/questions/52968315/cleartext-http-traffic-to-server-com-not-permitted
but I get an exception as soon as the app starts:
Unhandled Exception:
Java.Lang.RuntimeException:
The I tried to add
android:usesCleartextTraffic="true"
to the application node in AndroidManifest, but I get another exception:
Unhandled Exception:
Java.Lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: android.content.res.Resources$NotFoundException: Unable to find resource ID #0x7f080003
Is there a solution?
Thanks!
↧
↧
Good morning, i can´t resolve Plugin.InputKit error after install it, it appears follow code error:
Can not resolve reference: Plugin.CurrentActivity
, referenced by Plugin.InputKit
. Please add a NuGet package or assembly reference for Plugin.CurrentActivity
, or remove the reference to Plugin.InputKit
. SoftcomunaApp.Android
↧
Consume System.Drawing.Common package in Xamarin Android app?
My rendering code is now ported to .Net Standard 2.0 assemblies for portability.
Next step is to consume said assemblies in a Xamarin Android app.
However I do not seem to be able to consume for example the System.Drawing.Graphics type in my Xamarin code, even though I have added a reference to the System.Drawing.Common package.
Am I attempting the impossible? Must anything System.Drawing.Common be completely encapsulated in my .NET Standard assemblies? Or is there a viable workaround?
↧
Picker popup is shown twice when calling focus()
Hello
I've an issue when a Picker (in my example an ExtendedPicker, but it also happens with a normal Picker). In some cases (see below), when calling Picker's focus() method, the popup opens twice in Android simulator (not sure about iOS/real device).
In my case I've got a ListView with a Picker on each item. They work as long as I don't delete an item. After I deleted an item, on some still existing items when opening Picker, it's opened twice.
To reproduce the problem, you can load the project from here: https://github.com/skurth/App1
1) Start app
2) Delete group "Tübach City" by pressing "Delete" button next to it.
3) Press on one of the three "Kopf" buttons from group "PSW Tübach" (not from group "1. FC Schwangere Bergente", there still one popup opens correctly). They open a picker.
4) Press OK on the opened Picker.
5) Another picker popup is shown. Why?
Is there something I do wrong or is it a bug?
Relevant code is in file "ItemCell.cs", starting from line 39.
(The reason why I set picker IsVisble=false and using a button instead of the standard picker label is because I need to customize font etc., and this way it's easier than writing a custom renderer for Picker.)
↧
FileVersionInfo.GetVersionInfo gives file not found for Release
Hello Xamarin Guys and Girls.
I'm facing one strange problem, at least for me.
When I build my project in release, FileVersionInfo.GetVersionInfo throws FileNotFoundException. I need file version info to get the product version. Bellow is part of code.
...
Assembly asm = Assembly.GetExecutingAssembly();
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(asm.Location);
string productVersion = fvi.ProductVersion
....
Anyhow, I found workaround by using different approach
...
Assembly asm = Assembly.GetExecutingAssembly();
AssemblyName asmName = new AssemblyName(asm.FullName);
string productVersion = string.Format("{0}.{1}.{2}.{3}", asmName.Version.Major, asmName.Version.Minor, asmName.Version.Build, asmName.Version.Revision)
...
BUT, I would like to know what is going on here. Why do I get FileNotFoundException for release?
Regards,
Novak
↧
↧
Pickers opens box twice when focused after focus an entry
Hi everyone!!
I have a big issue that I can't solve from myself.
like the title says, in my android app (using xamarin.forms 3.4.0.1009999 after I updated from a very old version) when I select an entry, then tap over a picker, it opens twice.
A workaround I found is to place the picker in a StackLayout.. but when the picker is in a grid this workaround doesn't work.
Searching into the web, this issue should be resolved in release 3.4.0.1 so.. any ideas?
thanks!!!
↧
how can getdata from api and use fot recyclerview..
hi
i use this code but mpt in mainactivity and i got erorr in recycleradapter in itemcount that Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object. occurred
`
public override Java.Lang.Object InstantiateItem(ViewGroup container, int position)
{
View view = LayoutInflater.From(container.Context).Inflate(Resource.Layout.pager_item, container, false);
container.AddView(view);
mRecyclerView = view.FindViewById<RecyclerView>(Resource.Id.recycler);
mLayoutManager = new LinearLayoutManager(view.Context);
mRecyclerView.SetLayoutManager(mLayoutManager);
mclient = new WebClient();
Url = new Uri("http://www.aashuraian.ir/api/akhbarmashruhs");
mclient.DownloadDataCompleted += MclientOnDownloadDataCompleted;
mclient.DownloadDataAsync(Url);
mAdapter = new RecyclerAdapter(_akhbarMashruhs);
mRecyclerView.SetAdapter(mAdapter);
return view;
}
public void MclientOnDownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
{
var json = Encoding.UTF8.GetString(e.Result);
_akhbarMashruhs = JsonConvert.DeserializeObject<List<AkhbarMashruh>>(json);
}`
↧
Lost sqlite data in Windows 10 tablet after restart
Hi,
I developed small app using Xamarin Forms with SQLite database, data are saving in SQLite database in developer machine, no issue
after create store package (sideloading) for UWP
and after install one is my Windows tablet then app is working fine with data, but when after restart windows tablet, I lost all data
Please help
anything I am missing for windows tablet setting or anything else
Thanks
Rizwan
↧