试图弄清楚我是否可以禁用当用户点击ListView
中的单元格时发生的自动滚动(如果重要的话,我正在使用回收列表视图)。我已经将sender.SelectedItem
设置为null以禁用单元格突出显示。
gridList.ItemSelected += (s, e) => {
((Xamarin.Forms.ListView)s).SelectedItem = null;
};
更新 ItemTemplate布局
headline = new Xamarin.Forms.Label();
cellImage = new Xamarin.Forms.Image();
LoadingText = new Xamarin.Forms.Label();
LoadingText.Text = "Loading...";
layout = new Xamarin.Forms.Grid();
layout.RowDefinitions.Add(new Xamarin.Forms.RowDefinition { Height = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star) });
layout.ColumnDefinitions.Add(new Xamarin.Forms.ColumnDefinition { Width = new Xamarin.Forms.GridLength(1, Xamarin.Forms.GridUnitType.Star) });
layout.Children.Add(LoadingText, 0, 0);
layout.Children.Add(headline, 0, 0);
layout.Children.Add(cellImage, 0, 0);
layout.Children.Add(activityIndicator, 0, 0);
LoadingText.HorizontalOptions = Xamarin.Forms.LayoutOptions.CenterAndExpand;
LoadingText.VerticalOptions = Xamarin.Forms.LayoutOptions.CenterAndExpand;
layout.HorizontalOptions = Xamarin.Forms.LayoutOptions.CenterAndExpand;
layout.VerticalOptions = Xamarin.Forms.LayoutOptions.CenterAndExpand;
cellImage.HorizontalOptions = Xamarin.Forms.LayoutOptions.CenterAndExpand;
cellImage.VerticalOptions = Xamarin.Forms.LayoutOptions.CenterAndExpand;
if(!hasLoadedAdAtLeastOnce)
{
AdView.Content.TranslationY = 5;
AdView.Content.TranslationX = -20;
hasLoadedAdAtLeastOnce = true;
}
cellImage.WidthRequest = 260;
cellImage.HeightRequest = 173;
_ad = (Controls.Ad)AdView.Content;
View = layout;