我正试图让我的选择器是一个车轮/旋转类型。
我的当前选取器:
<Picker x:Name="AmountPicker" />
AmountPicker.ItemsSource = new List<string>() { "1", "2", "3","4","5","6","7","8" };
My Picker
zqdjd7g91#
你有两个选择。
wheel/spinning
1.1在共享项目中创建自定义选取器控件:
public class MyPicker : Picker { }
1.2在Android和iOS上创建自定义渲染器:
using Xamarin.Forms; using Xamarin.Forms.Platform.Android; [assembly: ExportRenderer(typeof(MyPicker), typeof(MyPickerRenderer))] namespace App35.Droid { class MyPickerRenderer : PickerRenderer { public MyPickerRenderer(Context context) : base(context) { } } }
[assembly: ExportRenderer(typeof(MyPicker), typeof(MyPickerRenderer))] namespace App35.iOS { class MyPickerRenderer : PickerRenderer { protected override void OnElementChanged(ElementChangedEventArgs<Picker> e) { base.OnElementChanged(e); } } }
1.3在XAML中使用它:
<local:MyPicker ItemsSource="{Binding MyListProperty}" ></local:MyPicker>
xmlns:syncfusion="clr- namespace:Syncfusion.SfPicker.XForms;assembly=Syncfusion.SfPicker.XForms
<syncfusion:SfPicker x:Name="picker" HeaderText="Choose Value" />
1条答案
按热度按时间zqdjd7g91#
你有两个选择。
wheel/spinning
类型。有一个类似的线程可以参考:Apply styles on Picker items in Xamarin Forms.1.1在共享项目中创建自定义选取器控件:
1.2在Android和iOS上创建自定义渲染器:
1.3在XAML中使用它:
xmlns:syncfusion="clr- namespace:Syncfusion.SfPicker.XForms;assembly=Syncfusion.SfPicker.XForms
。这样,您就可以在XAML中使用它,如下所示。有关详细信息,请参阅Getting Started with Xamarin Picker (SfPicker)