Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Xamarin Forms Picker Renderer default style template?

$
0
0

Hi, just a quick question hoping for a quick fix whilst I put more thought into this:

I'm creating custom renderers across all three platforms for the Xamarin Forms Picker view, which on Windows Phone 8.1 is currently looking like this:

    public class LabelPickerViewRenderer : PickerRenderer
    {
        public static void Init() { }

        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Picker> e)
        {
            base.OnElementChanged(e);

            this.Control.FontSize = 10;
            this.Control.Background = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.White);
            this.Control.Foreground = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Black);
            this.Control.BorderThickness = new Windows.UI.Xaml.Thickness(0);

        }
    }

In native Windows Phone I'm quite used to altering the default styles for any control as needed, hence want to add the default style template for the Picker to App.Xaml under Application.Resources.

To determine what the native Windows name is for the PickerRenderer I hovered my mouse over the 'this.Control' property above, to find that it says:

Windows.UI.Xaml.Controls.ComboBox VisualElementRenderer<Picker, ComboBox>.Control

and because of that assumed that copying the default style from the ComboBox at https://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj709912.aspx into Application.Resosurces, and modifying it.

The only default style that I can find for the ComBoBox is at https://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj709912.aspx and it has a Popup (which behaves like a drop-down instead of a picker, if you get my drift). Naturally I dropped it into Application.Resources, and as expected the 'full-screen' behaviour of the picker changed to a drop-down. It's as though the Windows Phone Silverlight 8.1 API shows a Windows RT ComboBox style instead of the Phone style.

Any ideas on how to modify the default style by adding something appropriate to Application.Resources?

Thanks,

Anthony


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>