Hi,
Could any one tried google assistant implementation with xamarin form.
It should be great if you have any samples.
Thanks in advance
Hi,
Could any one tried google assistant implementation with xamarin form.
It should be great if you have any samples.
Thanks in advance
We've created a behavior here that will be useful for a lot of people:
https://github.com/MelbourneDeveloper/Adapt.Presentation/blob/master/Adapt.Presentation.Standard/Adapt/Presentation/Behaviours/EntryPatternMatchValidationBehaviour.cs
The Entry control seems to lack a fair bit of basic functionality. One of those lacking features is the ability to specify a pattern matching Mask to stop the user from entering silly input. This behavior allows you to specify a Mask that will allow you to validate things like numbers at the field level. The Mask is specified in RegEx so it's very flexible.
Here is a XAML example that forces the user to only input a valid decimal number with two decimal places. I.e. non-numeric characters can not be entered:
<Entry Grid.Row="2" Text="{Binding Qty, Mode=TwoWay}" VerticalOptions="Center" Keyboard="Numeric">
<Entry.Behaviors>
<behaviours:EntryPatternMatchValidationBehaviour Mask="^\d+(?:\.\d{0,2})?$" Default="0" />
</Entry.Behaviors>
</Entry>
To see the sample, clone this repo which is a Xamarin library with a bunch of stuff that doesn't come out of the box in Xamarin. Try the Validation tab for this sample.
https://github.com/MelbourneDeveloper/Adapt.Presentation.git
Hi,
I have a question regarding the internal XAML Class Modifier.
I tried to set it to x:ClassModifier="internal"
or x:ClassModifier="NotPublic"
But by doing so I get the compiler error CS0262 (Partial declarations of 'type' have conflicting accessibility modifiers)
because I have already changed my codebehind file to internal also.
By looking at the *.g.cs File I see that the generated code is public partial class …
so I think it is not respecting
that x:ClassModifier Keyword or I am doing something wrong here ?
In my application I download the pdf from an API and store the file on the local file system. Then I try to open the pdf file with the built in viewer of the user. The next message appear:
*.pdf file exposed beyond app through intent.getdata().
public static void OpenPDF(Context context, string filePath)
{
//Open it up
Android.Net.Uri pdfPath = Android.Net.Uri.FromFile(new Java.IO.File(filePath));
Intent intent = new Intent(Intent.ActionView);
intent.SetDataAndType(pdfPath, "application/pdf");
intent.SetFlags(ActivityFlags.GrantReadUriPermission);
intent.SetFlags(ActivityFlags.NewTask);
intent.SetFlags(ActivityFlags.ClearWhenTaskReset);
context.StartActivity(intent);
}
Am i missing something?
I am fairly new to Xamarin. I'm currently working on a project and am trying to use best MVVM practices in building it. I've successfully implemented the MVVM pattern for my login page and I have a pretty good grasp on that, but it is a little more straight forward than what I'm trying to do now.
Once you log in you're brought to a TabbedPage. The TabbedPage contains two ContentPages, one with a ListView. My goal is to create an ObservableCollection which can be accessed by both of the ContentPages in the TabbedPage but I'm not sure where the correct place to create this ObservableCollection would be.
Should I create a ViewModel for the TabbedPage and have the ObservableList live there and have the ViewModels for the two ContentPages access that ViewModel? Should I create the ObservableList in the ViewModel of the first ContentPage with the ListView and have the second ContentPage reference that ViewModel?
I've tried looking for resources to understand this particular scenario but I haven't been able to find any that discuss multiple views referencing the same ObservableList. I'd be very grateful for either an explanation on the best way to do this, or a link to a resource that would explain or exemplify this. Thanks!
I should also note that I currently have the ObservableList living in the code behind for the ContentPage with the ListView. I know this is not where it should be but I just wanted to make sure I could get the ListView working with an ObservableList and I am now looking to move it to where it should be.
I have connected Bluetooth Mobile printer and wanted to design the receipt. I am new to xamarin. Is there a way to design it like crystal reports or other way. Please give me some suggestions. I wanted to create a receipt like this.
I tried like this to break into lines. How can we give spaces
public ICommand PrintCommand => new Command(async () =>
{
conn = DependencyService.Get<iSQLite>().SQLiteConnectionGetConnection();
PrintMessage = string.Empty;
PrintMessage += "\n" + "Test";
PrintMessage += "\n" + "No.200,Main Road";
PrintMessage += "\n" + "City";
PrintMessage += "\n" + "000-45615544";
await _blueToothService.Print(SelectedDevice, PrintMessage);
});`
But this showing like this.Telephone number is coming first.
000-45615544
Test
No.200,Main Road
City
I have a problem, migrate my project code VS 2017 to VS 2019.
And I have an error in the Android Manifest of a style.
When i back from a page,i want to cancel all threads of the page like playing sounds ..(working in viewmodel ) , what should i do ?
I've been experiencing this issue with my current app after setting target framework to android:targetSdkVersion="29". I've double checked that this happens with a sample application for easier debugging. This is replicated with the WorkingWithNavigation sample app.
Anytime a page is pushed or popped off the navigation stack this error occurs. I'm assuming this has to do with the animation of the navigation.
Any ideas or thoughts on how to fix this issue?
11-09 11:57:51.138 W/avigation.Droi(18447): Accessing hidden field Landroid/view/animation/Animation;->mListener:Landroid/view/animation/Animation$AnimationListener; (greylist-max-p, reflection, denied)
11-09 11:57:51.139 E/FragmentManager(18447): No field with the name mListener is found in Animation class
11-09 11:57:51.139 E/FragmentManager(18447): java.lang.NoSuchFieldException: No field mListener in class Landroid/view/animation/Animation; (declaration of 'android.view.animation.Animation' appears in /system/framework/framework.jar!classes3.dex)
11-09 11:57:51.139 E/FragmentManager(18447): at java.lang.Class.getDeclaredField(Native Method)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl.getAnimationListener(FragmentManager.java:1301)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl.setHWLayerAnimListenerIfAlpha(FragmentManager.java:1283)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl.completeShowHideFragment(FragmentManager.java:1746)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1822)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:797)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
11-09 11:57:51.139 E/FragmentManager(18447): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
11-09 11:57:51.139 E/FragmentManager(18447): at android.os.Handler.handleCallback(Handler.java:883)
11-09 11:57:51.139 E/FragmentManager(18447): at android.os.Handler.dispatchMessage(Handler.java:100)
11-09 11:57:51.139 E/FragmentManager(18447): at android.os.Looper.loop(Looper.java:214)
11-09 11:57:51.139 E/FragmentManager(18447): at android.app.ActivityThread.main(ActivityThread.java:7356)
11-09 11:57:51.139 E/FragmentManager(18447): at java.lang.reflect.Method.invoke(Native Method)
11-09 11:57:51.139 E/FragmentManager(18447): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
11-09 11:57:51.139 E/FragmentManager(18447): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
How to make a grid view, picture?
Hi xamarin forum
as my title says I encounter that error when I ran my app using this plugin
https://github.com/AlejandroRuiz/PayPal.Forms
I follow every step icluding the note on ReadME found below the page of that link how can I solve it?
Hello,
For most projects I click run arrow and it runs fine on my android device. But for some I click run arrow and it turns green again in a second. Nothing happens.
Help will be greatly appreciated.
Thanks
Hi all,
I have a custom renderer to add an icon to the right and/or left side of a date picker and to allow to draw a border on any side of the date picker.
This works fine as long as the icon I add is defined smaller than the size of the native controls frame.
If the icon is bigger than it seems the new size of the left/right view is not conciderered and the frame size stays the same.
I was able to fix that at least in drawing as the control is now drawn big enough.
However for some reason it seems the new size is not respected by Forms. For example if I have my custom date picker in a Stacklayouts and a button under it, then the button is very close to the date picker but there should be spacing. If I rotate from landscape to portrait, then the button even "slides" into the date picker.
My code for the custom iOS renderer looks like this:
public class CustomDatePickerIOSRenderer : DatePickerRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<DatePicker> e)
{
base.OnElementChanged(e);
if(Element is CustomDatePicker customPicker)
{
UpdateLeftIcon(customPicker);
UpdateRightIcon(customPicker);
}
}
public override void LayoutSubviews()
{
base.LayoutSubviews();
if (Element is CustomDatePicker customPicker)
{
ApplyBorder(customPicker);
}
}
protected virtual void ApplyBorder(CustomDatePicker customPicker)
{
Control.BorderStyle = UITextBorderStyle.None;
RemoveBorders();
nfloat height = Control.Frame.Size.Height;
if (leftView != null && leftView.Frame.Size.Height > height)
height = leftView.Frame.Size.Height;
if (rightView != null && rightView.Frame.Size.Height > height)
height = rightView.Frame.Size.Height;
Control.Frame = new CGRect(Control.Frame.X, Control.Frame.Y, Control.Frame.Width, height);
CGColor color = Element.IsFocused ? customPicker.BorderFocusedColor.ToCGColor() : customPicker.BorderColor.ToCGColor();
if (customPicker.Border.Left > 0)
CreateBorderSide(0, 0, customPicker.Border.Left, Control.Frame.Size.Height,color);
if(customPicker.Border.Right > 0)
CreateBorderSide(Control.Frame.Size.Width-customPicker.Border.Right,0, customPicker.Border.Right, Control.Frame.Size.Height, color);
if(customPicker.Border.Top > 0)
CreateBorderSide(0, 0, Control.Frame.Size.Width,customPicker.Border.Top, color);
if(customPicker.Border.Bottom > 0)
CreateBorderSide(0, Control.Frame.Size.Height-customPicker.Border.Bottom, Control.Frame.Size.Width, customPicker.Border.Bottom, color);
}
protected virtual void RemoveBorders()
{
//remove all previously added borders again (if any)
foreach (var layer in Control.Layer.Sublayers)
{
if (layer.Name != null && layer.Name.Contains("customBorder"))
layer.RemoveFromSuperLayer();
}
}
protected virtual void CreateBorderSide(double x,double y,double width,double height,CGColor color)
{
CALayer borderLayer = new CALayer();
borderLayer.Frame = new CGRect(x, y, width, height);
borderLayer.BackgroundColor = color;
borderLayer.Name = "customBorder";
Control.Layer.AddSublayer(borderLayer);
}
private UIView leftView, rightView;
protected virtual async void UpdateLeftIcon(CustomDatePicker customPicker)
{
if(customPicker.LeftIcon == null)
{
Control.LeftViewMode = UIKit.UITextFieldViewMode.Never;
Control.LeftView = null;
leftView = null;
}
else
{
leftView = await CreateSideView(customPicker.LeftIcon, customPicker.LeftIconSize);
Control.LeftView = leftView;
Control.LeftViewMode = UIKit.UITextFieldViewMode.Always;
}
}
protected virtual async void UpdateRightIcon(CustomDatePicker customPicker)
{
if (customPicker.RightIcon == null)
{
Control.RightViewMode = UIKit.UITextFieldViewMode.Never;
Control.RightView = null;
rightView = null;
}
else
{
rightView = await CreateSideView(customPicker.RightIcon, customPicker.RightIconSize, false);
Control.RightView = rightView;
Control.RightViewMode = UIKit.UITextFieldViewMode.Always;
}
}
protected virtual async Task<UIView> CreateSideView(ImageSource icon, int size, bool isLeft = true)
{
UIImage leftIconImage = await IosImageHelper.GetUIImageFromImageSourceAsync(icon);
CGSize iconSize = leftIconImage.Size;
if (size > -1)
iconSize = new CGSize((float)size, (float)size);
UIView paddingView = new UIView(new CGRect(0, 0, iconSize.Width + 8, iconSize.Height+8));
UIImageView sideView = new UIImageView(new CGRect(isLeft?8:0, 4, iconSize.Width, iconSize.Height));
sideView.Image = leftIconImage;
paddingView.AddSubview(sideView);
return paddingView;
}
}
So for me it highly seems like setting Control.LeftView or Control.RightView does not affect the actual frame size of the UIControl + it does not update the Xamarin Forms view bounds.
That's why I added the manual "calculation" of the border in ApplyBorder, but as it changes the frame of the iOS native control correctly, it seems to not update the information in the Xamarin Forms Control?
I guess the solution is very simple, somehow to notify the Xamarin Forms Control to remeasure or something but I just can't figure it out right now.
Here are screenshots showing what I mean by not keeping the distance and sliding into the control.
Landscape:
Portrait:
I have the following code trying to compress a bitmap and use it for uploading.
//1 Bitmap bitmap1 = BitmapFactory.DecodeByteArray(imageFileByte, 0, imageFileByte.Length);
//2 byte[] compressedData = null;
//3 using (var stream = new MemoryStream())
//4 {
//5 bitmap1.Compress(Bitmap.CompressFormat.Jpeg, 50, stream);
//6 compressedData = stream.ToArray();
//7 }
//8 //load compressed bitmap from memory
//9 using (var anotherStream = new MemoryStream(compressedData))
//10 {
//11 var compressedBitmap = BitmapFactory.DecodeStream(anotherStream);
//12 }
When I debug, bitmap1 on line 1 shows 3021330 bytes, when come to the compressedData on line 6, it did shrink to 70128 bytes. Now I want to convert again the compressedData to a bitmap again since it is a byte array but not a bitmap, when it comes to line 11, the compressedBitmap shows exactly same number of byte with the bitmap 1. How can I actually use the bitmap that has already been compressed? Is it possible to compress a bitmap and save the compressed one as a bitmap again? Thanks for any comment.
Hello Folks – I’m currently working as a Mainframe Developer. Me and my friends are planning to develop a Hybrid mobile app with Xamarin Forms. This app will do user management, allow them to make payments and plan their schedules. We are expecting 1000 users in the initial stage and go steadily thereafter. We are not sure at this moment which Database to use in the backend.
Could you please share your thoughts on which Database would be better for our use considering the user base, ease of integrating with Xamarin and minimal cost?
I created an android application with a foreground service that is always running. Initially, when the application is completely shut down (both process and service is not running), I try to use a broadcast to wake up the service, then my application take up 36MB of memory.
Next, I open the application and the memory usage grow up to 121MB. Finally, I tried to swipe out to kill the app, OnDestroy() method in MainActivity get called and I manually called GC.Collect() within this method, however, it's still take up 109MB of memory
My foreground service is just listening to step detector sensor and store the result to 'SharedPreferences' so I believe it won't take over hundred MB. Is there anyway to release more memory when the app is swiped out by user? Thank you.
Hi,
I have a Xamarin.Forms application which uses SQLite DB.
The SQLite DB is on my device (Android), and the App uses it for read/write operations.
Now, if I upload the app to the market, I would like the user to get an empty SQLite db in his device.
How can I cause my app to install an Empty db in the user's phone, while he installs the app?
Thank you,
Eliran
Hello,
I have a problem with a button on Xamarin.Forms. The button is a synchronize button what should enable a login form. By default login form is disabled but my synchronize button is also disabled while I don't want.
I searched on this forum and I tried differents methods like
<Button Text="Test" Command="{Binding SynchronizeButton}" IsEnabled="True"/>
instead of
<Button Text="Test" IsEnabled="True" Command="{Binding SynchronizeButton}"/>
My Login Form in Xaml
<Label Text="Id" IsEnabled="{Binding ActiveField, Mode=TwoWay}"/>
<Entry IsEnabled="{Binding ActiveField, Mode=TwoWay}"/>
<Label Text="Pass" IsEnabled="{Binding ActiveField, Mode=TwoWay}"/>
<Entry IsEnabled="{Binding ActiveField, Mode=TwoWay}"/>
My View Model (I'm using Prism)
public class MainPageViewModel : BindableBase
{
// Attributes
private INavigationService _navigationService;
private bool _activeField; (false by default)
public bool ActiveField
{
get { return _activeField; }
set
{
SetProperty(ref _activeField, value);
SynchronizeButton.RaiseCanExecuteChanged();
}
}
public DelegateCommand SynchronizeButton { get; private set; }
// Constructor
public MainPageViewModel()
{
SynchronizeButton = new DelegateCommand(Synchronize, CanSynchronize).ObservesProperty(() => ActiveField);
}
// Methods
private bool CanSynchronize()
{
return ActiveField;
}
private async void Synchronize()
{
ActiveField= true;
await _navigationService.NavigateAsync("MainPage");
}
}
Thanks for your help
Hi, I am working on the xamarin form. My requirement is to bind navigation menus at the bottom like
once I click on the more navigation pop up or sidebar should appear like
and I want to hide the hamburger menu button
How to achieve this?