问题
It is possible to make a UIPickerView
always visible in place where it is defined in XAML?
Standard behavior of this controls shows the binded list only when we clicked Title
property, then from the bottom of the screen (iOS) or in the popup(Android) is showing a widget which contains a list as a content.
I would like to make this visible from start and in the place where it is defined (not in the widget). There is no something like Position
in picker
object.
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
base.OnElementChanged(e);
List<string> names = new List<string>()
{
"test",
"test 2"
};
if (Control != null)
{
var picker = (UIPickerView)this.Control.InputView;
picker.ShowSelectionIndicator = true;
}
}
回答1:
I solved this problem and made a sample project repository available on GitHub.
Sample code:
<local:CustomObjectPicker
ItemsSource="{Binding ObjectList}"
SelectedItem="{Binding SelectedItem}"
IsTransparent="true"
TextColor="Blue"
/>
It is based on CustomRenderer
and works only on iOS since UIPickerView
is a native iOS control.
来源:https://stackoverflow.com/questions/38219874/customrenderer-for-uipickerview