Is there a way to select specific text and copy it to clipboard from xamarin label. I have found many samples but all them are copying full content. I need to select few words from paragraph.
Select and copy xamarin label specific text content
How does focus scope work in XF?
I'm using Rg.Plugins.Popup to show popups in an XF app.
The popups have their own focus scope, when you press tab you iterate through the focusable elements within the popup.
At certain scenarios however the background page which has its own focus scope can grab the focus from the popup.
I'm trying to prevent losing the focus but couldn't find much info about how any of this work in xamarin forms...
Is there a way to know when a page loses focus and possibly prevent that?
Or maybe a way to get/register on the current focused element?
How to set border width and shadow color of the frame?
I want to set the border width of a frame. how to set it?
and also the shadow color?
Mouse wheel event
Does XF expose any mouse wheel events?
Any workarounds?
Xamarin.Forms doesn't give enough love for tablets.
How to cancel navigation using OnNavigation override method? (Application Using Shell)
Hi to all,
I want to cancel a navigation due to validation reasons.
I find a method Cancel() from ShellNavigatingEventArgs parameter object in OnNavigating method but it doesn't work.
With the help of the debug mode i can check that even the Canceled property is change from false to true after using the Cancel() method. The Navigation continues anyway.
What am i missing here? Should i use other way to cancel the navigation ?
Regards.
Issues with DisplayActionSheet triggering exception
Hi,
I have some code that has been working okay until I came to perform some new testing this week.
I get the following error: System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.'
thrown when trying to use a DisplayActionSheet.
Initially I thought that there may be an issue with the TapGestureRecogniser that I'm using, but I get the same exception even when I use the following in the code behind:
var displayActionSheet = DisplayActionSheet("this is a test", "cancel", "bye");
I'm running this on Android 8.0.0 using Xamarin.Forms 4.4.0.99147.
Anyone else come across this?
How to use ExportRenderer for CarouselView in UWP
Hey, I got the error
"no suitable method found to override" in UWP Class
Shared Class
using Xamarin.Forms; namespace TestProject { public class MyCarouselView : CarouselView { public int NewPosition { get; private set; } public MyCarouselView(int newPosition) { Position = newPosition; } } }
UWP Class
using TestProject; using TestProject.UWP; using Xamarin.Forms; using Xamarin.Forms.Platform.UWP; [assembly: ExportRenderer(typeof(MyCarouselView), typeof(CarouselView_UWP))] namespace TestProject.UWP { public class CarouselView_UWP : CarouselViewRenderer { protected override void OnElementChanged(ElementChangedEventArgs<MyCarouselView> e) { base.OnElementChanged(e); if (e.NewElement != null) { e.NewElement.Position = e.NewElement.NewPosition; } } } }
ViewModel
int currentView = Convert.ToInt32(viewIndex); var newInt = new MyCarouselView(currentView);
Reference
https://forums.xamarin.com/discussion/56550/custom-renderer-and-parameters
Make Calloutdefinition clickable in ESRI
I'm using Esri Arcgis on my Xamarin project. I can show a callout on my map like this.
CalloutDefinition calloutDefinition = new CalloutDefinition("mycallout", "this is a callout"); calloutDefinition.ButtonImage = _infoIcon; calloutDefinition.OnButtonClick += calloutClicked; MyMapView.ShowCalloutAt(position, calloutDefinition);
But i want whole callout to be clickable not just the info button. I want to use calloutClicked in that event. Is it possible to do that?
ImageButton
Why does my imagebutton look like this?
I want the only picture to be shown.
Is it possible to make an xamarin forms app for eye glasses test
I have a request in which I need to implement eyeglasses power Test to calculate their Power of each eye(left & right). Can anybody suggest me something?
How to pass the nest json object parameters to api with httpclient ?
I need to pass a complex json object as parameters to api with httpclient, the json format like below:
and the problem is many of these objects are dynamic, for example, the "guid1" under photos will be more than one and the name will be difference:
guid1:{}, guid2{}, guid3{}...
also, the children under inspection_values are dynamic, it will be more than one
so how can I do that? thanks!
Getting Mono.AndroidTools.RequiresUninstallException on Android
Today I started getting this deployment error on android:
Severity Code Description Project File Line Suppression State
Error ADB0030: Mono.AndroidTools.RequiresUninstallException: The installed package is incompatible. Please manually uninstall and try again.
at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName) in E:\A_work\267\s\External\androidtools\Mono.AndroidTools\Internal\AdbOutputParsing.cs:line 339
at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass95_0.b__0(Task1 t) in E:\A\_work\267\s\External\androidtools\Mono.AndroidTools\AndroidDevice.cs:line 753 at System.Threading.Tasks.ContinuationTaskFromResultTask
1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at AndroidDeviceExtensions.d__11.MoveNext() in E:\A_work\267\s\External\androidtools\Xamarin.AndroidTools\Devices\AndroidDeviceExtensions.cs:line 187
--- End of stack trace from previous location where exception was thrown ---
at AndroidDeviceExtensions.d__11.MoveNext() in E:\A_work\267\s\External\androidtools\Xamarin.AndroidTools\Devices\AndroidDeviceExtensions.cs:line 194
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at AndroidDeviceExtensions.d__11.MoveNext() in E:\A_work\267\s\External\androidtools\Xamarin.AndroidTools\Devices\AndroidDeviceExtensions.cs:line 203
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Xamarin.AndroidTools.AndroidDeploySession.d__112.MoveNext() in E:\A_work\267\s\External\androidtools\Xamarin.AndroidTools\Sessions\AndroidDeploySession.cs:line 414
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Xamarin.AndroidTools.AndroidDeploySession.d__106.MoveNext() in E:\A_work\267\s\External\androidtools\Xamarin.AndroidTools\Sessions\AndroidDeploySession.cs:line 217
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Xamarin.AndroidTools.AndroidDeploySession.d__104.MoveNext() in E:\A_work\267\s\External\androidtools\Xamarin.AndroidTools\Sessions\AndroidDeploySession.cs:line 119 0
It only happens in Debug, but in Release i can deploy and run the app just fine.
Why is this happening?
This morning i installed the Android SDK 10.0 and I suspect it started after that, so now I uninstalled it, but I still can't deploy because of the same error.
Other apps from the same PC can be deployed just fine, so I don't get it...
I did check this out
https://docs.microsoft.com/en-us/xamarin/android/errors-and-warnings/adb0030
but I don't even have my app installed on the device...
Thanks
How to do a Close Confirmation with a Xamarin Forms mac App?
I have a Xamarin.Forms application for iOS, Android, and now hopefully Mac. I made all the adjustments for the UI to look great on Mac. Submitted it for approval where it was rejected because the user can close the window where the Xamarin Forms UI is running, but the app itself and menu bar continue running. So I figure I would just add a confirmation pop-up asking if they want to exit the app when they try to close the window. OK = Terminate the App. Cancel = Keep the window open. I find lots of articles on how to handle this with a Xamarin.Mac app, but nothing on how to handle Xamarin.Forms on mac. The FormsApplicationDelegate does not give access to the View Controller or the Window Delegate in order to override the WindowShouldClose method. I found that I can use NSAlert to do the pop-up which works great. Now I cannot find anything on what to do when the user responds. I also can figure out how to quit the app via code in the mac project. Open to suggestions.
private void Window_WillClose(object sender, System.EventArgs e)
{
NSNotification senderNotification = ((NSNotification)sender);
NSWindow closingWindow = (NSWindow)senderNotification.Object;
var confirmation = new NSAlert() { AlertStyle = NSAlertStyle.Warning, InformativeText = "Are you sure you want to exit the App?", MessageText = "Exit?" }; confirmation.AddButton("OK"); confirmation.AddButton("Cancel"); var result = confirmation.RunModal(); if (result == 1001) { //Cancel closing the window } else { //terminate the app } }
BUG - CustomViewCell with CustomBehavior - Value is set on multiple editors
Problem noticed only on android.
When I set a value to an editor, the same value is also set on other editor of the listview, when you scrolldown.
- Create a listview
- Set a custom DataTemplate
- Create dynamic editors on the DataTemplate
- Set a Behavior to the editors : editor MUST have custom Keyboard, or bug wont appear.
- Bug when you set a value on an editor.
MainPage.xaml
<ListView x:Name="list" HasUnevenRows="True" SelectionMode="None" />
MainPage.xaml.cs
List<string> l = new List<string> { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }; list.ItemsSource = l; list.ItemTemplate = new DataTemplate(typeof(ViewCellTest));
ViewCellTest.xaml
<ViewCell.View> <StackLayout x:Name="stack"> <Label Text="{Binding .}" /> </StackLayout> </ViewCell.View>
ViewCellTest.xaml.cs
public ViewCellTest() { InitializeComponent(); Editor curView1 = new Editor(); Editor curView2 = new Editor(); curView1.Behaviors.Add(new EditorBehaviorTest()); curView2.Behaviors.Add(new EditorBehaviorTest()); stack.Children.Add(curView1); stack.Children.Add(curView2); }
EditorBehaviorTest.cs
class EditorBehaviorTest : Behavior<Editor> { public EditorBehaviorTest() { } protected override void OnAttachedTo(Editor entry) { entry.TextChanged += OnEntryTextChanged; entry.Keyboard = Keyboard.Telephone; base.OnAttachedTo(entry); } protected override void OnDetachingFrom(Editor entry) { entry.TextChanged -= OnEntryTextChanged; base.OnDetachingFrom(entry); } private void OnEntryTextChanged(object sender, TextChangedEventArgs args) { if (!string.IsNullOrWhiteSpace(args.NewTextValue)) { bool isValid = true; //do some controls ((Editor)sender).Text = isValid ? args.NewTextValue : args.NewTextValue.Remove(args.NewTextValue.Length - 1); } } }
How to open a view after clicking on a notification
Hello,
I started development under XAMARIN for 2 months and I can't seem to do the following:
I have a crossPlateform application with a side menu. Each line corresponds to a different view containing each of the webView. I also implemented "Azure notification Hub" to manage notifications on both platforms. The problem is that I would like to be able to open on a view which changes according to a key word defined in the payload.
Here is an example of the side menu that I have created :
All the views are created in the common project but the notifications are managed in the project of each platform. How can I do, for example from the android project, open on the Traficolor view after clicking on the notification since the views are not defined in this project?
How to fix "cannot convert from 'TouchTracking.TouchTrackingPoint' to 'Xamarin.Forms.Point'"?
Hello everyone, hope your doing well.
I've been attempting to create a simple page in my app which allows the user to draw on the screen by following the code posted by Microsoft. However I must have mucked something up something as currently I'm being faced with the error "cannot convert from 'TouchTracking.TouchTrackingPoint' to 'Xamarin.Forms.Point'". Does anyone know how to fix this?
Xaml
<?xml version="1.0" encoding="UTF-8"?> <pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:d="http://xamarin.com/schemas/2014/forms/design" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:skia="clr-namespace:SkiaSharp.Views.Forms;assembly=SkiaSharp.Views.Forms" xmlns:tt="clr-namespace:TouchTracking.Forms;assembly=TouchTracking.Forms" x:Class="NEA_I_MDL.Misc.Notes_Popup" xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"> <Grid BackgroundColor="White"> <skia:SKCanvasView x:Name="CanvasView" PaintSurface="CanvasView_PaintSurface"></skia:SKCanvasView> <Grid.Effects> <tt:TouchEffect Capture = "True" TouchAction="TouchEffect_TouchAction"></tt:TouchEffect> </Grid.Effects> </Grid> </pages:PopupPage>
C#
using SkiaSharp; using TouchTracking; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Xamarin.Forms; using Xamarin.Forms.Xaml; using SkiaSharp.Views.Forms; namespace NEA_I_MDL.Misc { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class Notes_Popup { Dictionary<long, SKPath> ActivePaths = new Dictionary<long, SKPath>(); List<SKPath> FinishedPaths = new List<SKPath>(); SKPaint Paint = new SKPaint { Style = SKPaintStyle.Stroke, Color = SKColors.Black, StrokeWidth = 10, StrokeCap = SKStrokeCap.Round, StrokeJoin = SKStrokeJoin.Round }; public Notes_Popup() { InitializeComponent(); } private void CanvasView_PaintSurface(object sender, SkiaSharp.Views.Forms.SKPaintSurfaceEventArgs e) { } SkiaSharp.SKPoint ConvertToPixel(Point pt) { return new SKPoint((float)(CanvasView.CanvasSize.Width * pt.X / CanvasView.Width),(float)(CanvasView.CanvasSize.Height*pt.Y / CanvasView.Height)); } private void TouchEffect_TouchAction(object sender, TouchTracking.TouchActionEventArgs args) { switch (args.Type) { case TouchActionType.Pressed: if (!ActivePaths.ContainsKey(args.Id)) { SKPath path = new SKPath(); path.MoveTo(ConvertToPixel(args.Location)); ActivePaths.Add(args.Id, path); CanvasView.InvalidateSurface(); } break; case TouchActionType.Moved: if(ActivePaths.ContainsKey(args.Id)) { SKPath path = ActivePaths[args.Id]; path.LineTo(ConvertToPixel(args.Location)); CanvasView.InvalidateSurface(); } break; case TouchActionType.Released: if(ActivePaths.ContainsKey(args.Id)) { FinishedPaths.Add(ActivePaths[args.Id]); ActivePaths.Remove(args.Id); CanvasView.InvalidateSurface(); } break; case TouchActionType.Cancelled: if (ActivePaths.ContainsKey(args.Id)) { ActivePaths.Remove(args.Id); CanvasView.InvalidateSurface(); } break; } } void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args) { SKCanvas Canvas = args.Surface.Canvas; Canvas.Clear(); foreach(SKPath i in FinishedPaths) { Canvas.DrawPath(i, Paint); } foreach (SKPath path in ActivePaths.Values) { Canvas.DrawPath(path, Paint); } } } }
Thank you for your time
Changing Tint of Toolbar Item Icon
I've been looking for days but couldn't find a way to change the tint color of a toolbar item on Android like on iOS
UINavigationBar.Appearance.TintColor = Color.FromHex("#FFFFFF").ToUIColor();
I found and applied lots of answers including defining your own style in xml but they just change back button color, title text color so on.
Is there a proper way to change toolbar items tint?
Any help would be appreciated.
Profile image storage in app from web api
I have a method in my XF app that calls an api and streams an Image, amongst other pieces of data, from a db. In this particular viewmodel method I am saving this data in memory as ImageSource and then bound to the view. However, I would like to use this image in various other places within the app, ideally without having to make the same exact api call all over. What is the best practice to save this data in the app so i can use it across other viewmodels without having to call the api each time?
I have looked at FFImageLoading, and would ideally like to use a cached version of this image all over my app, but unclear what the 'Source' would be.
'Fragment already added: LoadingPlatformDialog{a1d0181
Good Day
I am sing https://github.com/muak/AiForms.Dialogs
i implemented an example which works perfect. i can move between pages
Configurations.LoadingConfig = new LoadingConfig { IndicatorColor = Color.White, OverlayColor = Color.Black, Opacity = 0.4, DefaultMessage = "Loading Languages , Please wait...", }; Loading.Instance.Show(); await Task.Delay(5000); await Navigation.PushAsync(new Page2()); Loading.Instance.Hide();
and it shows the loading Panel nicely. now i implemented this in my main Project and i get an error
****Java.Lang.IllegalStateException:** 'Fragment already added: LoadingPlatformDialog{a1d0181 #1 LoadingDialog}'**
Thanks
Loading does not Show
Good Day all
i have a loading functionality that shows on the long running part of my code. it does not show , here is how i use it
Configurations.LoadingConfig = new LoadingConfig { IndicatorColor = Color.White, OverlayColor = Color.Black, Opacity = 0.4, DefaultMessage = "Sending you an Sms, Please wait...", }; await Loading.Instance.StartAsync(async progress => { await obj.Generate_Sms_Verification_code(GenericMethods.USER_DATA); });
and the function Generate_Sms_Verification_code is defined like this
public async Task Generate_Sms_Verification_code(USERS_Model model) { con = new SqlConnection(strCon); cmd = new SqlCommand(); cmd.CommandText = "dbo.Sms_Verification_code"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@PARAMETER", SqlDbType.NVarChar).Value = model.PARAMETER; cmd.Connection = con;cmd.CommandTimeout = 0; string code = string.Empty; try { con.Open(); code = cmd.ExecuteScalar().ToString(); try { await SendSms(GenericMethods.RemoveSpacesIn_String(model.TELEPHONE), "Your APP Code is, " + code + ", Kindly Dont share this code with anyone"); } catch (Exception ex ) { throw ex; } } catch (SqlException ex) { throw ex; } finally { con.Close(); }
i am using AiForms.Dialogs for Xamarin.Forms which can be found here https://github.com/muak/AiForms.Dialogs#loading
Thanks