Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all 91519 articles
Browse latest View live

Hi guys ! Someone knows how to click on a collectionView to display content with mvvm


HorizontalTextAlignment not working

$
0
0

i updated xamarin forms to the latest version yesterday (4.3.0.947036) ,and now for some reason text alignment for Entry control is not working on android, but works fine for IOS.
anybody got a solution for this?

ViewCell Selected Background Color in iOS 13

$
0
0

Prior to iOS 13, you could set a background color in a ViewCell, and change that background color to another color when the cell is pressed. The color change would start on the press down and reset on release. The press feedback no longer works in iOS 13 if you use a cell background color other than transparent.

I need to use a cell background color to get the style I want in my app. Does anyone know a way to use a cell background color and get a touch effect in iOS 13 in a ListView? I've tried a number of approaches, but they all just capture the press release, not the press down. I did manage a workaround for cells in a TableView, but I still need help for cells in a ListView. Thanks!

how do i create a cross platform social media(ios and android)photo feed in xamarin.forms

$
0
0

i want to create a efficient photo feed in which i will be loading information from firebase database such as username, the photo url, likes, comments, and description and want to make a photo feed that acts as kinda a recycler view for its efficiency. and I do not know how at all

Barcode reader for handheld devices like zebra and Panasonic devices in xamat

$
0
0
I am developing the barcode reader application which supports only handheld devices like zebra bad Panasonic's devices. Please anyone tell me how to do barcode reader for those devices in XamarinForms.

Thanks in advance

EfganHuseynov

$
0
0

in 1st Xaml Page selected Picker item (Country) I want to Bind 3rd Xaml Page ...
Please help me!!

Problem with custom renderer height (iOS)

$
0
0

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:

Shell close animation stuttering on Android

$
0
0

Hi,

today I experimented a bit with the "new" (not that new anymore) shell component in order to set up a simple hamburger menu.
I'm facing the same issue as with the MasterDetailPage in the past, were the animation of closing the menu is stuck for a second before actually closing.
For the Masterdetail it was solved by adding a delay (which was bad already) but I can't find a way to solve it for shell.

Does anyone know how to improve the closing animation? Right now it is unusable.

Here is my xaml setup:

<?xml version="1.0" encoding="UTF-8"?>
<Shell BackgroundColor="#D4503B"  xmlns="http://xamarin.com/schemas/2014/forms" xmlns:page="clr-namespace:MyApp.ContentPages" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="MyApp.AppShell">
    <FlyoutItem Title="Dashboard" >
            <Tab>
                <ShellContent ContentTemplate="{DataTemplate page:Page1}"/>
            </Tab>
    </FlyoutItem>
    <FlyoutItem Title="Train ticket request">
            <Tab>
                <ShellContent ContentTemplate="{DataTemplate page:Page2}" />
            </Tab>
    </FlyoutItem>
    <FlyoutItem Title="Parking spot reservation">
            <Tab>
                <ShellContent ContentTemplate="{DataTemplate page:Page3}" />
            </Tab>
    </FlyoutItem>
</Shell>

Page 1 is almost empty, just two buttons without any styling are shown there but the same problem. Page2 and 3 are a bit more complex but still not overwhelmingly crazy.

One of my ideas was to manually tell when to open and close and navigate but I didn't find a way how to implement it (For example, how to get the menu icon click event?)
Any ideas?

I'm using Xamarin.Forms 4.3.0.947036

References confirming the bug (One is marked as solved but clearly isn't):
https://github.com/xamarin/Xamarin.Forms/issues/7521
https://github.com/xamarin/Xamarin.Forms/issues/5216

References to fix MasterDetail in the past:
https://github.com/xamarin/Xamarin.Forms/issues/4398
https://stackoverflow.com/questions/48115810/how-can-i-make-the-masterdetailpage-faster-on-android


How to display image in app from firebase storage using image url.

$
0
0

How to display images in app from firebase storage using image url. it is not displaying image from image url.

Touch passthrough to video player below canvas

$
0
0

For my application, I need to have a video player below the canvas view (in xamarin forms). The problem with this, however, is users cannot use the built in player controls because the canvas is swallowing those events. My question is, is it possible to allow touch passthrough on the canvas so when the user clicks play, the video will play?

Running NUnit tests in App Center throws Exception

$
0
0

We have a Xamarin Forms solution which we are building and deploying through App Center. We have added an NUnit test project to this solution which must automatically be run when building in App Center. To get this to run we added the following scripts as described in the Microsoft Documentation:

https://docs.microsoft.com/en-us/appcenter/build/troubleshooting/xamarin#i-want-to-run-unit-tests-for-my-xamarin-application-how-can-i-do-that

When we run this build on AppCenter we got the following Exception when the NUnit ConsoleRunner tries to run the unit tests:

1) Error : 
Exception has been thrown by the target of an invocation.


Server stack trace: 
  at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x0001a] in <0523ad94f2e04325802cd231c518c8d9>:0 
  at System.Reflection.RuntimeConstructorInfo.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0007a] in <0523ad94f2e04325802cd231c518c8d9>:0 
  at System.Reflection.RuntimeConstructorInfo.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <0523ad94f2e04325802cd231c518c8d9>:0 
  at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x0022b] in <0523ad94f2e04325802cd231c518c8d9>:0 
  at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00095] in <0523ad94f2e04325802cd231c518c8d9>:0 
  at System.Activator.CreateInstance (System.String assemblyString, System.String typeName, System.Boolean ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Security.Policy.Evidence securityInfo, System.Threading.StackCrawlMark& stackMark) [0x00077] in <0523ad94f2e04325802cd231c518c8d9>:0 
  at System.Activator.CreateInstance (System.String assemblyName, System.String typeName, System.Boolean ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Security.Policy.Evidence securityInfo) [0x00016] in <0523ad94f2e04325802cd231c518c8d9>:0 
  at System.AppDomain.CreateInstance (System.String assemblyName, System.String typeName, System.Boolean ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Security.Policy.Evidence securityAttributes) [0x0000e] in <0523ad94f2e04325802cd231c518c8d9>:0 
  at (wrapper remoting-invoke-with-check) System.AppDomain.CreateInstance(string,string,bool,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo,object[],System.Security.Policy.Evidence)
  at System.AppDomain.CreateInstanceAndUnwrap (System.String assemblyName, System.String typeName, System.Boolean ignoreCase, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Security.Policy.Evidence securityAttributes) [0x00000] in <0523ad94f2e04325802cd231c518c8d9>:0 
  at (wrapper remoting-invoke-with-check) System.AppDomain.CreateInstanceAndUnwrap(string,string,bool,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo,object[],System.Security.Policy.Evidence)
  at (wrapper xdomain-dispatch) System.AppDomain.CreateInstanceAndUnwrap(object,byte[]&,byte[]&,string,string,bool)

Exception rethrown at [0]: 
  at (wrapper xdomain-invoke) System.AppDomain.CreateInstanceAndUnwrap(string,string,bool,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo,object[],System.Security.Policy.Evidence)
  at (wrapper remoting-invoke-with-check) System.AppDomain.CreateInstanceAndUnwrap(string,string,bool,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo,object[],System.Security.Policy.Evidence)
  at NUnit.Engine.Drivers.NUnit3FrameworkDriver.CreateObject (System.String typeName, System.Object[] args) [0x00000] in <7b0953727751470ab10f0e0b547b85ae>:0 
  at NUnit.Engine.Drivers.NUnit3FrameworkDriver.Load (System.String testAssemblyPath, System.Collections.Generic.IDictionary`2[TKey,TValue] settings) [0x0009e] in <7b0953727751470ab10f0e0b547b85ae>:0 
  at NUnit.Engine.Runners.DirectTestRunner.LoadPackage () [0x000d0] in <7b0953727751470ab10f0e0b547b85ae>:0 
  at NUnit.Engine.Runners.TestDomainRunner.LoadPackage () [0x00017] in <7b0953727751470ab10f0e0b547b85ae>:0 
  at NUnit.Engine.Runners.DirectTestRunner.EnsurePackageIsLoaded () [0x00008] in <7b0953727751470ab10f0e0b547b85ae>:0 
  at NUnit.Engine.Runners.DirectTestRunner.RunTests (NUnit.Engine.ITestEventListener listener, NUnit.Engine.TestFilter filter) [0x00000] in <7b0953727751470ab10f0e0b547b85ae>:0 
  at NUnit.Engine.Runners.AbstractTestRunner.Run (NUnit.Engine.ITestEventListener listener, NUnit.Engine.TestFilter filter) [0x00000] in <7b0953727751470ab10f0e0b547b85ae>:0 
  at NUnit.Engine.Agents.RemoteTestAgent.Run (NUnit.Engine.ITestEventListener listener, NUnit.Engine.TestFilter filter) [0x00000] in <7b0953727751470ab10f0e0b547b85ae>:0 
  at (wrapper managed-to-native) System.Runtime.Remoting.RemotingServices.InternalExecute(System.Reflection.MethodBase,object,object[],object[]&)
  at System.Runtime.Remoting.RemotingServices.InternalExecuteMessage (System.MarshalByRefObject target, System.Runtime.Remoting.Messaging.IMethodCallMessage reqMsg) [0x000b5] in <0523ad94f2e04325802cd231c518c8d9>:0 

Exception rethrown at [1]: 
  at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (System.Runtime.Remoting.Proxies.RealProxy rp, System.Runtime.Remoting.Messaging.IMessage msg, System.Exception& exc, System.Object[]& out_args) [0x0014d] in <0523ad94f2e04325802cd231c518c8d9>:0 
  at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_remoting_wrapper(intptr,intptr)
  at (wrapper remoting-invoke) NUnit.Engine.Agents.RemoteTestAgent.Run(NUnit.Engine.ITestEventListener,NUnit.Engine.TestFilter)
  at NUnit.Engine.Runners.ProcessRunner.RunTests (NUnit.Engine.ITestEventListener listener, NUnit.Engine.TestFilter filter) [0x00025] in <7b0953727751470ab10f0e0b547b85ae>:0 

Test Run Summary
  Overall result: Failed
  Test Count: 0, Passed: 0, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
  Start time: 2019-08-20 11:17:19Z
    End time: 2019-08-20 11:17:20Z
    Duration: 0.751 seconds

To exclude any issues in the Unit Test project I created a new empty project and tried to run this, but this throws the same Exception.

Is anybody sucessfully running (N)Unit-tests in App Center? Any tips on how to accomplish this?

How to read a backspace in an Entry from Xamarin.Forms?

$
0
0

I can't for the life of me capture the backspace! I need to capture a backspace, even if the field is empty. Am I doing something wrong?

public class CustomEntryRenderer: EntryRenderer, Android.Views.View.IOnKeyListener
{
    protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
    {
        base.OnElementChanged(e);

        if (Control == null) 
        {
            return;
        }

        var entry = (CustomEntry)Element;

        Control.SetOnKeyListener(this);

        Control.KeyPress += (s, arg) => { 
            System.Diagnostics.Debug.WriteLine("OnElementChanged KeyPress");
        };

        Control.TextChanged += (s, ev) => { 
            System.Diagnostics.Debug.WriteLine("OnElementChanged TextChanged"); 
        };

        Control.EditorAction += (s, ev) =>
        {
            System.Diagnostics.Debug.WriteLine("EditorAction EditorAction");
        };

        Control.SetOnEditorActionListener(this);


    }

    public override bool OnKeyPreIme(Keycode keyCode, KeyEvent e)
    {
        System.Diagnostics.Debug.WriteLine("OnKeyPreIme");
        return base.OnKeyPreIme(keyCode, e);
    }

    public override bool OnKeyUp(Keycode keyCode, KeyEvent e)
    {
        System.Diagnostics.Debug.WriteLine("OnKeyUp");
        return base.OnKeyUp(keyCode, e);

    }



    protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
    {
        base.OnElementPropertyChanged(sender, e);

        if (Control == null)
        {
            return;
        }

        var entry = (CustomEntry)Element;

        Control.SetOnKeyListener(this);

        Control.KeyPress += (s, arg) =>
        {
            System.Diagnostics.Debug.WriteLine("OnElementPropertyChanged KeyPress");
        };

        Control.TextChanged += (s, ev) =>
        {
            System.Diagnostics.Debug.WriteLine("OnElementPropertyChanged KeyPress");
        };

        Control.EditorAction += (s, ev) => { 
            System.Diagnostics.Debug.WriteLine("OnElementPropertyChanged EditorAction");
        };

    }

    bool IOnKeyListener.OnKey(Android.Views.View v, Keycode keyCode, KeyEvent e)
    {
        System.Diagnostics.Debug.WriteLine("OnKey");
        return true;
    }


}

How to show xamarin.ios chart view in xamairn form?

$
0
0

Hi, I want to used Any Chart library in xamarin form, but Any chart is not available for xamarin form, so I have decided to embed Anychart library in xamarin.ios and by some way used in xamarin form, is it possible? Thanks

How to play audio from byte[]

$
0
0

I would like to play audio from the byte[], that is being streamed.

Xamarin Form 4.0, Shell hamburger Icon

$
0
0

Hello,

How can I add "hamburger.png" icon for iOS and UWP app with the shell flyout ?

Thanks.


Xamarin Forms 4.3.0.908675 Device Open Uri

$
0
0

Hi everyone !

I have now updated my project to xamarin forms 4.3.0.908675. Before updating, I was using device.openUri (https: example.com) to redirect the user to the browser and it worked fine. But, after the update this code(Device.OpenUri) did not work. Probably this code in this version of xamarin forms deprecate.

I found the following to solve this;

  • Launcher.TryOpenAsync()
  • Launcher.CanOpenAsync()
  • Launcher.OpenAsync()

What kind of solution should I apply? Looking forward to your valuable suggestions.

Thanks in advance !

How to execute javascript code in html source of Webview?

$
0
0

My app receives articles from wordpress, through a converter I clean the html code and then with StringBuilder I create the new html string that I feed to a WebView, here I'd like to add an ADV javascript widget (the script is external). Do you believe it is possible?

ListView inside CarouselView scroll vertical is almost impossible.

$
0
0

I have a collection of listviews inside a horizontal CarouselView. When im trying to scroll vertically through the listview in focus, if make any tiny movement horizontally, the carousels horizontal scrolling "takes over" and makes scrolling vertically almost impossible. Anyway i can "prioritize" the listviews scrolling?

Hope it makes sense :)

Does grialkit is freely available in visual studio? If yes how to use in our solution?

$
0
0

I was searching for a free UI tool kit for xamarin forms, I found GRAIL kit. Is it free to use, If yes how to use in xamarin forms and if no is there any kit that is free?

Does anyone have examples of connecting Google Play Services to get a leaderboard?

$
0
0

Does anyone have examples of connecting Google Play Services to get a leaderboard?

Viewing all 91519 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>