CustomRenderer for UIPickerView

霸气de小男生 提交于 2019-12-11 04:48:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!