I have a class C# file called Mycode.cs
and
I have a XAML page called MyDesign.xaml having a Label in it
What code should I write in Mycode.cs page to type in the label belonging to a completely different page?
I have a class C# file called Mycode.cs
and
I have a XAML page called MyDesign.xaml having a Label in it
What code should I write in Mycode.cs page to type in the label belonging to a completely different page?
I have a situation where typed text doesn't go to the currently displayed page.
See the sample code below.
When the TestPage appears, click in Entry A to give it focus.
Then click the Click Me button.
The new page appears as you'd expect.
Now start typing on your physical keyboard (on my emulator the soft keyboard will appear as I type)
As Entry B does not have focus, the typed letters don't appear in Entry B.
Hit the Back button to dismiss the keyboard.
Hit the Back button to dismiss the new page.
Now we're back to TestPage, and strangely the text entered via the keyboard is now in Entry A.
It seems strange to me that keyboard entry would go to the page behind. This behaviour can also be demonstrated with two pages in a TabbedPage, so if Tab 1 contains an entry, give it focus. Then select Tab 2 and then type, go back to Tab 1, and observe the typed text is in that entry.
Is this expected? Is there an easy way I can prevent this behaviour?
I'm using VS2019, and Xamarin Forms v4.6. Running with an Android Emulator with API28.
public class TestPage : ContentPage { public TestPage() { StackLayout stackLayout = new StackLayout(); Entry entry = new Entry() { Placeholder = "Entry A"}; Button button = new Button() { Text="Click Me"}; stackLayout.Children.Add(entry); stackLayout.Children.Add(button); Content = stackLayout; button.Clicked += Button_Clicked; } private async void Button_Clicked(object sender, EventArgs e) { ContentPage page = new ContentPage(); page.Content = new Entry() { Placeholder = "Entry B"}; await Navigation.PushModalAsync(new NavigationPage(page)); } }
ccavenue payment gateway integration with Xamarin forms
Hi,
I use VS2017 created a shared xamarin.forms project, today i installed the latest version of vs2019 and all the related SDK for Xamarin.forms
Use the new vs2019 to open the share project which created in vs2017, clean all and rebuild and make the apk file, test the new apk in my phone, seems everything looks good.
But when i click add new item, in the dialog i can't see the Xamarin.Forms in the left panel list
And when i created a new xamarin.forms project with vs2019, i can see the Xamarin.Forms in the Create new item dialog
Can someone tell me why? How to resolve this issue? My old shared project only contain Android project, no IOS and winPhone project, seems there is no share project in vs2019, do we need to change the shared project to normal one? How to change that?
Thanks inadvance!
Hi everybody,
I have extendedentry and custom renderer classes
` public class ExtendedEntryRenderer : EntryRenderer
{
/// <summary> /// Called when [element changed]. /// </summary> /// <param name="e">The e.</param> protected override void OnElementChanged(ElementChangedEventArgs<Entry> e) { base.OnElementChanged(e); if (Control != null) { Control.Click += (sender, evt) => { var nativeEditText = (global::Android.Widget.EditText)Control; nativeEditText.SetSelectAllOnFocus(true); new Handler().PostDelayed(delegate { Control.InputType = 0; try { InputMethodManager inputMethodManager = Control.Context.GetSystemService(Android.Content.Context.InputMethodService) as InputMethodManager; if (inputMethodManager != null) { inputMethodManager.HideSoftInputFromWindow(Control.WindowToken, HideSoftInputFlags.None); } } catch (Exception Ex) { } }, 300L); }; // Hide soft input keyboard Control.FocusChange += (sender, evt) => { // Select all on entry focus var nativeEditText = (global::Android.Widget.EditText)Control; nativeEditText.SetSelectAllOnFocus(true); new Handler().PostDelayed(delegate { Control.InputType = 0; try { InputMethodManager inputMethodManager = Control.Context.GetSystemService(Android.Content.Context.InputMethodService) as InputMethodManager; if (inputMethodManager != null) { inputMethodManager.HideSoftInputFromWindow(Control.WindowToken, HideSoftInputFlags.None); } } catch (Exception Ex) { } }, 300L); }; } } }`
`public class ExtendedEntry : Entry
{
}`
And my XAML file is like this:
`
<Entry.Triggers>
</Entry.Triggers>
</local:ExtendedEntry>`
Trigger isnt work.
But when i change normal entry control like this:
`
<Entry.Triggers>
</Entry.Triggers>
</Entry>`
Trigger is work.
Where did i wrong?
Thanks.
I'm trying to add font awesome icons to my tabbed page tabs. I've followed what I believe are the correct steps to be able to configure display font awesome icons for Xamarin.forms applications but for some reason the icons display for the android app but not the iOS app.
I first added the font awesome .ttf files to the android Assets folder and the iOS Resources folder:
Next I updated the Info.plist file for iOS in order to include the .ttf files from Font Awesome:
Then I configured use of the Font Awesome icons in App.xaml:
Finally I added the needed icons to the their tabs:
VS 2019, latest updates. So far only doing Android, but am wondering if I will run into the same problem for other OS's. When I deploy to the Android Emulator - Pixel 3a Pie 9.0 - API 28 (Android 10.0 - API 29), everything lines up nicely. When I deploy to my phone, Samsung SM-G935V (Android 8.0 - API 26), everything is off. Some lines, with a label, and entry widgets, the label is wrapped to two lines. The entry's on the bottom do not show (off the screen).
So, what should I do to try to fix this? How should I proceed (what should I be looking at\reading), so that I can adjust for the different versions of Android, and different android phones? Is my emulator version to high (but if I code for a lower version of Android, what happens when an install is done on a higher version)?
Thanks for any help or direction.
Hello,
My Xamarin.forms program allows the user to choose a photo from the Downloads folder and then import that photo into an SQLite database.
Since installing the Pixel 2 Q 10.0 - API29 emulator, I got an error message: Downloads: Access Denied. The program therefore cannot access the photo, and the photo is not updated in the database. I specify that it worked perfectly with the Pixel 2 Pie 9.0 - API 28 emulator.
I know Google has made some security changes, but what changes do you need to make in the Xamarin.forms program to get permission to access the Downloads folder?
Thank you for your reply.
i have a Tabbed view like whatsup and the Main View is defined like this
<?xml version="1.0" encoding="utf-8" ?> <TabbedPage x:Class="WhatsApp.Views.MainView" xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:views="clr-namespace:WhatsApp.Views" Title="Trova" NavigationPage.HasBackButton="False" > <TabbedPage.Padding> <OnPlatform x:TypeArguments="Thickness" iOS="0, 20, 0, 0" /> </TabbedPage.Padding> <views:SearchMain BackgroundColor="Transparent"/> <views:MatchesView /> <views:ChatsView BackgroundColor="Transparent" /> <views:ViewsLikes BackgroundColor="Transparent" /> </TabbedPage>
The InitililizeComponent takes time ,
try { InitializeComponent(); } catch (Exception ex) { throw ex; }
i placed a try catch to check if there is no exception in the xaml.
What could be a problem
Hello,
My oxyplot chart works on Android only, on iOS nothing happens.xmlns:oxy="clr-namespace:OxyPlot.Xamarin.Forms;assembly=OxyPlot.Xamarin.Forms"> <oxy:PlotView x:Name="appChart" VerticalOptions="Center" HorizontalOptions="Center" />
Code behind is simple chart with 2 lines in AppDelegate.cs:global::Xamarin.Forms.Forms.Init(); OxyPlot.Xamarin.Forms.Platform.iOS.PlotViewRenderer.Init();
I move OxyPlot.Xamarin.Forms.Platform.iOS.Forms.Init() before global::Xamarin.Forms.Forms.Init(), but again blank screen.
No errors... Can you help me?
Hi,
I am using customised entry. I need to implement validation for customised entry in which field shoud take only numbers. No alphabets , no special character, no dots are allowed.
Can anyone help me how to implement validation for customised entry
ccavenue payment gateway integration with Xamarin forms
Hello, the title is a bit clickbaity, made as a joke
I'm not a professional, yet, but hoping to become one pretty soon!
I have 3 years of hobbistic experience with C++, but never designed nor developed a GUI.
Always used Visual Studio so, here I am with Xamarin.Forms and C#.
Now, I'm developing an offline Diet Diary for my own purposes and also as a portfolio app.
I learned just the basics, then I looked for frameworks and found FreshMVVM (also MVVM Cross and Prism) and chosen it for its semplicity as my application is not complex.
The fact is that FreshMVVM allows me to access the View directly from the ViewModel, so I designed my application to be ViewModel centric, where the View will contain XAML code only, no C# at all.
This is against the MVVM pattern. I'm experienced enough to see that this will not have any impact on my application, due to its simplicity, but that's not how the MVVM pattern works.
It's better to show you how the application will work, more or less.
This is an example so it has less pages than the real application has.
3 pages, 3 View Models
Page | View | ViewModel | Model |
---|---|---|---|
Food | X | X | X |
FoodList | X | X | |
Meal | X | X | X |
Food Model
public int Type { get; set; } public string Name { get; set; } public int KCal { get; set; }
Food ViewModel
FoodList View
FoodList ViewModel
Meal Model
public DateTime Day { get; set; } // when did we eat? public int Type { get; set; } public List<Food> FoodEaten { get; set; }
Meal ViewModel
Meal View
Shows the data
The fact is that FreshMVVM has methods that controls the navigation between the pages through the ViewModel, also allowing to pass data between them, so I can do this:
// The parameters are pseudocode to show how the data is transfered // Sends to the Food ViewModel the food's data + how it should CoreMethods.PushPageModel<FoodPageModel>(open in VIEW mode, food to show);show them // From the FoodList ViewModel we return to the Meal ViewModel with the list of selected food item that we ate CoreMethods.PopPageModel(return selected foods to the Meal);
The navigation is more or less like this:
Master-Detail page -> FoodList in View mode <--> Food (all modes) Master-Detail page -> Meal in View or Create mode <--> FoodList in Selection mode <--> Food (all modes)
The View is being controlled by the ViewModel through properties like IsEditing
or IsSaving
and stuff like that.
But how do I tell the View in which mode I need to be? Because this changes how the Toolbar is populated, which items it has and which not.
For instance in VIEW mode, I can only start editing, so I add 1 toolbaritem with the EditCommand. In EDIT/CREATE mode I have Save/Cancel toolbar items etc.
Honestly I don't know how to do it without passing by the ViewModel itself, and at that point why should I use C# in the View?
Hi there,
I´m premising that I´m new with mobile development and actually I´m developing an App using Xamain.Forms and Xamarin.Essentials
Now my goal is to start a call programmatically and handle the events of start call and end call.
To start the call I´m using Xamarin.Essentials PhoneDialer and it is not a problem, but I cannot found the way to handle the events of that call, and in particular StartOfCall and EndOfCall.
Somebody can help ?
Thank you in advance
Good night guys, I have a chat application where each user has their image. The aplicitvo works offline and the users' images are in the local bank (SQLite) in BASE64.
To display these images in the chat list and other elements what is the best way?
1) Load the images into memory by converting BASE64 to an image.
2) Generate the images physically in an APP folder and use the physical path.
3) Another suggestion.
If anyone has been through this scenario, please give me a light.
I've set up login endpoint in AWS which returns an access token in the response. I've stored this token in Application.Current.Properties
I want to use the access token as I need the user to be signed into the app to be allowed to upload images.
I've set up an S3 bucket, but need to know how I can configure a new s3 client to upload to this bucket
e.g:
var s3Client = new AmazonS3Client("appClientId", "appClientSecret", Application.Current.Properties["access_token"].ToString()); // how to configure this part? var images = GetIPhoneImagesFromFolder(); foreach (var image in images) { var bArray = ImageSourceToBytes(image.imageSource); var base64String = Convert.ToBase64String(bArray); try { byte[] bytes = Convert.FromBase64String(base64String); using (s3Client) { var request = new PutObjectRequest { CannedACL = S3CannedACL.PublicRead, Key = string.Format("MyFolder/{0}", image.imageSource) }; using (var ms = new MemoryStream(bytes)) { ms.Position = 0; request.InputStream = ms; s3Client.PutObjectAsync(request); } } }
Hello all,
Can anyone please help me to understand how to call nested item click event in prism?
Hello
I am developing a cross platform app for Android and iOS.
I am using an insecure HttpClientHandler for a HTTPS connection with my webservice.
It is a strange issue. I can connect to the web service on my machine with both Android device and iOS emulator but with another server, the connection only works with iOS.
With Android , I get the following error:
The SSL connection could not be established, see inner exception.
Inner exception ->
Unable to read data from transport connection. Connection reset by peer. error code 10054.
I have already checked that both my machine and server have a valid SSL certificate assigned to the required port.
The service running is the same on both. iOS app works, Android doesn't.
Any ideas??
in same code same project in xamarin forms
Navigation between pages is slow just on android on ios it is good
these video for IOS it is good speed
https://drive.google.com/open?id=162U0XmPw-NZvMZhqNgyDOtCPcy52EhHy
these for Android it slow not good like IOS
https://drive.google.com/open?id=15yedNiqzwypFx8RIN22UTltFmCSIIFIl
these my simple
https://drive.google.com/open?id=1eK-6efyw37LUH78p3ze-fflWXJI_3tlQ
thank you
I am using webview for playing video and audio in my projects like the below screenshot.
I need to capture the video/audio playtime when going back from that page. I research about this but didn't get anything useful.
Is there any way to fetch the video/audio playtime?
Update
Video: XAML
<local:VideoWebview x:Name="web_view" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"> </local:VideoWebview>
XAML.CS
if (Device.RuntimePlatform == Device.iOS) { Device.BeginInvokeOnMainThread(() => { web_view.Url = videourl; }); } else { web_view.Source = videourl; }
Audio: XAML
<WebView x:Name="web_view" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"> </WebView>
XAML.CS
web_view.Source = audiourl;
Sample Video URL: https://player.vimeo.com/video/434126696?api=1&player_id=player1
Sample Audio URL: http://catholic-brain.s3.amazonaws.com/qa/dc/cbrain-app/files/doc-lib/2017/08/16/11/21/59/604/head/Catholic-brain-01-The-Rosary-Song.mp3
I am using a custom renderer in ios video webview for the transparent background.
public class VideoWebviewRenderer : ViewRenderer<VideoWebview, WKWebView> { WKWebView wkWebView; protected override void OnElementChanged(ElementChangedEventArgs<VideoWebview> e) { base.OnElementChanged(e); if (Control == null) { WKWebViewConfiguration configuration = new WKWebViewConfiguration(); configuration.AllowsInlineMediaPlayback = true; wkWebView = new WKWebView(CGRect.Empty, configuration); //transparent background wkWebView = new WKWebView(CGRect.Empty, configuration); wkWebView.BackgroundColor = UIColor.Clear; wkWebView.ScrollView.BackgroundColor = UIColor.Clear; wkWebView.Opaque = false; if (Element.Url != null) { wkWebView.LoadRequest(new NSUrlRequest(new NSUrl((Element).Url))); } SetNativeControl(wkWebView); } } protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName.Equals(nameof(Element.Url))) { wkWebView.LoadRequest(new NSUrlRequest(new NSUrl((Element).Url))); } } public override void Draw(CGRect rect) { base.Draw(rect); Control.Frame = rect; } }