IconToolbarItem with Iconize not click event - xamarin

I am currently developing a Xamarin.Forms application. I am using IconizePlugin. The app is tabbedPage based and on toolbar I'm trying to include icons for some actions.
This is whay I'm getting:
Icons are showing well and in Xamarin.iOS gets the click event, while it is not working in Xamarin.Droid.
I included the corresponding nugets and followed every steps told in documentation and can't archive this. Other iconize controls in Droid are working fine except the IconToolbarItem.
Please help!

The workaround I found was to declare de IconToolbarItem in the c# code instead of xaml. Although I don't know why it wasn't working while on xaml.
Declaring the item li
ToolbarItems.Add(new IconToolbarItem
{
Icon = "fa-plus",
IconColor = Color.White,
Command = new Command(this.addBono)
});

Related

How to add trivial OpenGL functionality to Xamarin forms app

Can anyone please help with the following?
I have a trivial Xamarin forms app working and I want to add an OpenTK view.
The following works fine:
In my MainPage.xaml.cs I have the following event handler for a button which spawns an empty OpenTK view on each click:
private void OnXAMLButtonClicked(object sender, EventArgs e)
{
var view = new OpenGLView { HasRenderLoop = true };
view.HeightRequest = 300;
view.WidthRequest = 300;
view.OnDisplay = r =>
{
//GL.ClearColor(red, green, blue, 1.0f);
};
m_SL.Children.Add(view);
}
(where m_SL is the name of my StackLayout).
I get a new black window on each click. Great.
Now, see that commented-out line, that's because the value GL is undefined.
This code is from the simple example here:
https://learn.microsoft.com/en-us/dotnet/api/xamarin.forms.openglview?view=xamarin-forms
I see at the top of that example there is the following:
using OpenTK.Graphics.ES30;
But I cannot include this, OpenTK is not recognized as a namespace. I expected to have to add it as a reference, but how?
I can add a reference to it in my .Android project so that I can add the above using statement in my MainActivity.cs page but that is not where it belongs (although I see that I then have GL defined, so this proves that I need to add these using statements to my MainPage.xaml.cs in order to get GL defined), but like I say, how do I add the reference to OpenTK for the project that contains MainPage.xaml.cs.
Thanks for any help,
Mitch.
----- EDIT -----
Thanks to the poster for helping me so far, the new problem is a reference to System.Private.Core that cannot be resolved. Here's the my full workflow for creating this error:
1: Create a new project.
This gives me the three projects:
2: Change to .NET standard 2.1 in the OGLMobile project:
The .Android and .iOS projects don't have a .NET choice option.
3: Add reference to OpenTK to OGLMobile project:
4: OGLMobile project builds fine but .Android project gives:
If I remove reference to OpenTK everything builds again. Makes no difference if I add OpenTK Nuget package to .Android project, I still get the same error.
So close,
thanks for any advice.
You need to install Nuget Package OpenTK.Graphics, then can use that.
Now can refer it:
Note: 4.0.1 of OpenTK.Graphics need .NET Standard 2.1.

Xamarin WebView sometimes doesn't show in UWP

I have a WebView that shows the terms and conditions when the user starts the app. That WebView contains a few links. Currently, I have the terms and conditions as a html file that I store in resources.
In the code-behind I fill the WebView via:
public partial class Agb : ContentPage
{
public Agb()
{
InitializeComponent();
BindingContext = new ViewModel.AgbViewModel();
Web.Source = new HtmlWebViewSource
{
Html = Properties.Resources.Agb
};
Web.Navigating += WebViewNavigating;
}
XML:
<WebView
x:Name="Web"
VerticalOptions="FillAndExpand"
Margin="50,0"/>
Most of the time this works well. On UWP this WebView sometimes fails to show. It always shows on my own computer but randomly fails in production.
Is there anything I can do to get the WebView to work reliably?
Option 1:
I've made a pull request to fix this bug in Xamarin.Forms, so simply update Xamarin.Forms to a version, where it will be merged.
However, while the fix is not yet there and while the fix may not be available for earlier versions of Xamarin.Forms before 4.4.0, here's how to fix it in your project:
Option 2
Add the WebViewRenderer_fix.cs file to your project. This file is based on v4.4.0, but if you see build errors, you may need to apply the fix yourself to earlier version of this file.
And don't forget to register it as a custom renderer for your WebView
[assembly: ExportRenderer(typeof(WebView), typeof(WebViewRenderer_fix))]

Create a size changing Editor in Xamarin

I want to create a Xamarin Forms Editor Control that changes its height when it gets filled(Adds a new line when space in previous line finished). I'm only interested in WinPhone and Android Platfroms.
The Editor itself doesn't support such property.
I know that the Android native control (EditText) supports it (Not sure about the WinPhone variant, TextBox). But I'm not sure how to implement it.
It will be very helpful if someone can explain me how to create the renderers for these platforms.
Edit
I found this partial solution, it kind of works fine but it is not so natural(as for example EditText in Android).
class RoundedEditor : Editor
{
public RoundedEditor()
{
this.TextChanged += (sender, e) => { this.InvalidateMeasure(); };
}
}
I'll be glad if someone will provide a better solution.
Edit 2
Here are the results of how it works now:
UWP
Writing first line:
pressing enter:
The previous line is not showed completely as I would like.
Android
In android it actually works great:
You will have to implement a custom Android EditText, and then use it for your XamarinForms control (by implementing a custom renderer for it)
Take a look at this implementation of resizable EditText:
https://github.com/ViksaaSkool/AutoFitEditText
You'd have to translate it to C# obviously, but its a great start point.

Unable To Share Text On Xamarin Form

Hello Everyone I want to share the Text on Xamarin Form using Library plugin.share. I have successfully implemented the library and on android i can able to share the text but in iOS it returns me nothing. i have done the share code on button click event so when i click on button in iOS its doesn't returns me anything.i tried the Below code but doesn't got succeed
CrossShare.Current.Share("Hii alll", "Share");
please help me to get out of this,thanks in advance
You want to take a look at UIActivityViewController, you can find the documentation here https://developer.xamarin.com/api/type/MonoTouch.UIKit.UIActivityViewController/
And Xamarin.Forms specific example http://devcenter.wintellect.com/jwood/implementing-sharing-in-xamarin-forms
This is a bit old, but I was having a similar issue and was able to resolve it.
First of all, you need to add the plugin Plugin.Share to ALL Xamarin.Forms projects (Portable, iOS, Android, UWP).
In the class that references the share code, add...
using Plugin.Share;
using Plugin.Share.Abstractions;
CrossShare.Share() doesn't work with strings, directly. You need to new up a ShareMessage.
var title = "Title For The Share";
var message = "Text to share.";
await CrossShare.Current.Share(new ShareMessage { Text = message, Title = title });
I can't say specifically to iOS, as I don't have a Mac and can't test that project, but Android and Windows 10 is working.

Add marker on map with label in Xamarin Android

I'm creating a Xamarin Android App in Visual Studio.
I've added a Google map v2 to my app, and also added markers. On tap of these markers, I've opened an info window.
Now, I want to customize these markers, so that markers are displayed with label on the top of it, like below:
Please suggest with code, for how to do this in Xamarin. I'm new to this environment.
You can use android-maps-utils as binding-library.
Sample app is here - oystehei/MapsUtilityDemo: Demo project for Google Maps Utility bindings project in Xamarin.
How to add a "text on marker" is described as follows.
var iconGen = new IconGenerator(activity);
var markerOp = new MarkerOptions().SetPosition(latLng);
iconGen.SetStyle(IconGenerator.StyleOrange);
markerOp.SetIcon(BitmapDescriptorFactory.FromBitmap(
iconGen.MakeIcon("text_on_marker")));
gogleMap.AddMarker(markerOp);

Resources