I have updated a Xamarin Forms proyect to 4.2 and I'm usign a CollectionView with an entry for each data template. The "problem" is that when I tap on a entry I get a weird little underline under all the entries in the list.
Honestly I don't know from where this underline is come from!
Here you can see a little grey underline under the "00"
EDIT:
I have discovered that is a small horizontal scroll bar, here I have created another collection view (yeah, the binding is totally random, but I want a fast example) and I have set HorizontalScrollBarVisibility="Never" but it is still showed (it's a CollectionView property not entry...).
Code:
<StackLayout>
<CollectionView x:Name="ItemsListView"
ItemsSource="{Binding Items}"
VerticalOptions="FillAndExpand"
HorizontalScrollBarVisibility="Never"
ItemsUpdatingScrollMode="KeepScrollOffset">
<d:CollectionView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>First Item</x:String>
<x:String>Second Item</x:String>
<x:String>Third Item</x:String>
<x:String>Fourth Item</x:String>
<x:String>Fifth Item</x:String>
<x:String>Sixth Item</x:String>
</x:Array>
</d:CollectionView.ItemsSource>
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout>
<StackLayout Orientation="Horizontal"
BackgroundColor="AntiqueWhite"
Padding="10"
Margin="10">
<Entry WidthRequest="50" />
<Entry WidthRequest="50" />
</StackLayout>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
There is a way to remove it? or at least make it appears only in the entry selected?
P.S. I think I haven't mentioned it, it appears only for some second (when tap on an entry) and then disappears.
you could use custom render to custom the entry,for example:
custom an Entry MyEntry :
public class MyEntry :Entry
{
}
then in Android project,create a entry render AndroidEntry :
[assembly: ExportRenderer(typeof(MyEntry), typeof(AndroidEntry))]
namespace App18.Droid
{
class AndroidEntry:EntryRenderer
{
public AndroidEntry(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control !=null)
{
Control.SetSingleLine(true);
Control.HorizontalScrollBarEnabled = false;
}
}
}
}
then in axml use your custom entry :
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout>
<StackLayout Orientation="Horizontal"
BackgroundColor="AntiqueWhite"
Padding="10"
Margin="10">
<local:MyEntry WidthRequest="50" />
<local:MyEntry WidthRequest="50" />
</StackLayout>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>