2
votes

I have a scrollView with a Grid inside which contains several Entrys.

When I click anywhere on the screen that isn't one of the Entry controls the focus automatically goes to the first Entry I have on the grid. I.e. This happens whether any Entry already has Focus or not, it will always set the focus of the first one again.

If I remove the Scrollview and have the Grid on screen on it's own I don't get this issue.

I am developing an application for a Windows 10 device but using the Xamarin forms cross platform code as we may move the code to Android at some stage.

Thanks in advance.

2
is there any reason that you dont use listview instead of scrollview with datagrid? because it is adviced by xamarin not to use it like that when you can achieve with listview - Emil
We use grids because it has more flexibility in the way we can display data onto the screen. There are a number of base classes we use to populate the screen with controls purely by giving it the controls you want. We wouldn't be able to display data and controls in the same way using ListViews - iandavidson1982
I never tried this way but you may check some 3rd party like xlabs, syncfusion etc. they have datagrids like wpf style. maybe this is what you are looking for. beside that you can try to achieve it using custom layouts like xamarin suggests in their evolve 2016. this video might be helpful youtube.com/watch?v=sxjOqNZFhKU&t=1169s - Emil
Thanks i'll take a look. It's frustrating that this out of the box control has to be fudged to work correctly. But that's par for the course with Xamarin... - iandavidson1982
fairly talking xamarin forms is not mature enough yet. if your app has more business logic than UI, use XF but If you consider more beautiful app with native look UI, better to use xamarin native. I tell you from my experience, many people think that XF reduced DEV time but other way around, it will increase with such bugs, workarounds etc. especially if you consider no IOS version, it is easier to do Win10 and Android on native. - Emil

2 Answers

1
votes

I was able to reproduce the described behavior on UWP Windows 10, but not on Android or iOS, so this is a bug in the Forms code for UWP.

I have filed a bug report for this issue which you can track here: https://bugzilla.xamarin.com/show_bug.cgi?id=52613

Xamarin engineers will now discuss this issue on the bug report. If you would like to receive a notification when the bug is updated, you can add yourself to the CC list for the bug. Please note that you will need to create an account on that system if you have not already done so.

0
votes

I don't know if you solved your problem because it was more than a year ago and the issue @jgoldberger has opened on Xamarin's Bugzilla did not progress since last October.

Nevertheless I just noticed the same behaviour on my UWP app and after looking around the internet I found a solution.

If you look at this thread : Why does my TextBox get focused when clicking inside of ScrollViewer?

Then it is easy to imagine a solution for a Xamarin.Forms app by creating a custom renderer inside your UWP project.

You can use the following code which is working perfect for me :)

using {your_project_namespace}.UWP;
using Xamarin.Forms;
using Xamarin.Forms.Platform.UWP;

[assembly: ExportRenderer(typeof(ScrollView), typeof(ScrollViewCustomRenderer))]

namespace {your_project_namespace}.UWP
{
    public class ScrollViewCustomRenderer : ScrollViewRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<ScrollView> e)
        {
            base.OnElementChanged(e);

            if (Control == null)
                return;

            Control.IsTabStop = true;
        }
    }
}

Hope this helps. Cheers