public PickerGettingStarted() { collectionStrings = new List <string>(); collectionStrings.Add("Blue"); collectionStrings.Add("Black"); collectionStrings.Add("Red"); collectionStrings.Add("Pink"); collectionStrings.Add("Orange"); collectionStrings.Add("Magenta"); collectionStrings.Add("Yellow"); collectionStrings.Add("Purple"); collectionStrings.Add("Green"); collectionStrings.Add("Gray"); collectionStrings.Add("LightGray"); collectionStrings.Add("Brown"); pickerControl = new SfPicker(); pickerControl.SelectionChanged += PickerControl_ValueChanged; pickerControl.ItemsSource = collectionStrings; this.Add(pickerControl); eventLog = new UILabel(); eventLog.Lines = 0; eventLog.Text = "Event Log :"; eventLog.BackgroundColor = UIColor.White; eventLog.LineBreakMode = UILineBreakMode.WordWrap; table = new UITableView(this.Bounds); // defaults to Plain style tableItems = new string[100]; Add(eventLog); table.Source = new TableSourceCollection(tableItems); Add(table); }
protected override void OnAttachedTo(ContentPage bindable) { base.OnAttachedTo(bindable); dataForm = bindable.FindByName <SfDataForm>("dataForm"); dataForm.DataObject = new ContactInfo(); dataForm.RegisterEditor("CustomPickerEditor", new DataFormEditorExe(dataForm)); dataForm.RegisterEditor("Color", "CustomPickerEditor"); picker = bindable.FindByName <SfPicker>("picker"); picker.BindingContext = new ColorInfo(); picker.SelectionChanged += Picker_SelectionChanged; var footerView = bindable.FindByName <Button>("footerView"); footerView.Clicked += OnPickerClosed; }
public PickerGettingStarted() { collectionStrings = new List <string>(); collectionStrings.Add("Blue"); collectionStrings.Add("Red"); collectionStrings.Add("Pink"); collectionStrings.Add("Orange"); collectionStrings.Add("Magenta"); collectionStrings.Add("Yellow"); collectionStrings.Add("Green"); collectionStrings.Add("LightGray"); collectionStrings.Add("Brown"); pickerControl = new SfPicker(); pickerControl.SelectedIndex = 2; pickerControl.ShowColumnHeader = true; pickerControl.HeaderText = "Select a Color"; pickerControl.ColumnHeaderText = "Colors"; pickerControl.ShowFooter = false; pickerControl.ShowHeader = true; pickerControl.SelectionChanged += PickerControl_ValueChanged; pickerControl.ItemsSource = collectionStrings; pickerControl.BackgroundColor = UIColor.FromRGBA(255, 0, 255, 0.3f); this.Add(pickerControl); eventLog = new UILabel(); eventLog.Lines = 0; eventLog.Text = "Event Log :"; eventLog.BackgroundColor = UIColor.White; eventLog.LineBreakMode = UILineBreakMode.WordWrap; table = new UITableView(this.Bounds); // defaults to Plain style tableItems = new string[100]; Add(eventLog); table.Source = new TableSourceCollection(tableItems); Add(table); }
public override View GetSampleContent(Context con) { float height = con.Resources.DisplayMetrics.HeightPixels;; LinearLayout layout = new LinearLayout(con); Typeface tf = Typeface.CreateFromAsset(con.Assets, "Segoe_MDL2_Assets.ttf"); layout.Orientation = Android.Widget.Orientation.Vertical; sfpicker = new SfPicker(con); sfpicker.ShowHeader = true; List <String> source = new List <string>(); source.Add("Yellow"); source.Add("Green"); source.Add("Orange"); source.Add("Lime"); source.Add("LightBlue"); source.Add("Pink"); source.Add("SkyBlue"); source.Add("White"); source.Add("Red"); source.Add("Aqua"); sfpicker.ItemsSource = source; sfpicker.LayoutParameters = new ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, (int)(height * 0.60)); sfpicker.PickerMode = PickerMode.Default; sfpicker.ShowFooter = false; sfpicker.SelectedItemTextSize = 20 * con.Resources.DisplayMetrics.Density; sfpicker.UnSelectedItemTextSize = 20 * con.Resources.DisplayMetrics.Density; sfpicker.HeaderHeight = 40 * con.Resources.DisplayMetrics.Density; sfpicker.ShowColumnHeader = false; sfpicker.UnSelectedItemTextColor = Color.Black; sfpicker.SelectedIndex = 7; float density = con.Resources.DisplayMetrics.Density; eventLog = new TextView(con); eventLog.LayoutParameters = new ViewGroup.LayoutParams(800, 400); layout.SetGravity(GravityFlags.CenterHorizontal); layout.AddView(sfpicker); string headerText1 = "PICK A COLOR"; sfpicker.ShowHeader = true; sfpicker.HeaderText = headerText1; sfpicker.BorderColor = Color.Red; TextView textview = new TextView(con); textview.Text = "Event Log"; textview.Typeface = tf; textview.SetTextColor(Color.Black); textview.TextSize = 20; if (density > 2) { textview.SetPadding(20, 0, 0, 20); } else { textview.SetPadding(10, 0, 0, 10); } layout.AddView(textview); var scrollviewer = new ScrollView(con); var textFrame = new LinearLayout(con); textFrame.Orientation = Android.Widget.Orientation.Vertical; scrollviewer.AddView(textFrame); scrollviewer.VerticalScrollBarEnabled = true; FrameLayout bottomFrame = new FrameLayout(con); bottomFrame.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, (int)(height)); bottomFrame.SetBackgroundColor(Color.Silver); bottomFrame.AddView(scrollviewer); bottomFrame.SetPadding(10, 30, 10, 0); layout.AddView(bottomFrame); sfpicker.ColumnHeaderText = "COLOR"; sfpicker.OnSelectionChanged += (sender, e) => { eventLog = new TextView(con); eventLog.SetTextColor(Color.Black); if (textFrame.ChildCount == 6) { textFrame.RemoveViewAt(0); } textFrame.AddView(eventLog); eventLog.Text = (e.NewValue).ToString() + " " + "has been Selected"; Color color = PickerHelper.GetColor(e.NewValue.ToString()); sfpicker.SetBackgroundColor(color); sfpicker.Background.Alpha = 128; // scrollviewer.ScrollTo(0, textFrame.Bottom); }; return(layout); }
void CreatePicker() { if (!m_init) { Forms.Init(); SfPickerRenderer.Init(); m_init = true; } m_picker = new SfPicker(); ViewX = UtilsiOS.ConvertFormsToNative(m_picker, m_rect); string str1 = "", str2 = "", str3 = "", str4 = ""; Utils.Extract(m_data, ref str1, ref str2, ref str3, ref str4); if (!string.IsNullOrEmpty(str1)) { double rowHeight = Utils.ConvertToDouble(str1); if (rowHeight > 0) { rowHeight = AutoScaleFunction.TransformSize((int)rowHeight, (int)UtilsiOS.GetScreenSize().Width); m_picker.ItemHeight = rowHeight; } } m_picker.ShowHeader = !string.IsNullOrEmpty(str2); if (m_picker.ShowHeader) { m_picker.HeaderHeight = 40; m_picker.HeaderText = str2; } m_picker.ShowColumnHeader = !string.IsNullOrEmpty(str3); if (m_picker.ShowColumnHeader) { m_picker.ColumnHeaderHeight = 40; m_picker.ColumnHeaderText = str3; } m_picker.ShowFooter = false; m_picker.SelectedIndex = 0; m_picker.PickerMode = PickerMode.Default; m_picker.PickerWidth = m_rect.Width; m_picker.PickerHeight = m_rect.Height; m_picker.BackgroundColor = Color.Transparent; m_picker.HeaderBackgroundColor = Color.Transparent; m_picker.ColumnHeaderBackgroundColor = Color.Transparent; m_picker.HeaderTextColor = Color.Black; m_picker.UnSelectedItemTextColor = Color.LightGray; m_picker.SelectedItemTextColor = Color.Black; m_picker.SelectionChanged += (sender, e) => { ActionDelegate?.Invoke(WidgetName, e.NewValue.ToString()); }; m_picker.OnPickerItemLoaded += (sender, e) => { if (m_pics == null) { return; } int row = e.Row; CustomRowView view = new CustomRowView(m_rect.Width); if (m_pics.Count > row) { UIImageView rowPic = new UIImageView(m_pics[row]); view.AddSubview(rowPic); } if (m_strings != null && m_strings.Count > row) { UILabel rowText = new UILabel(); rowText.Text = m_strings[row]; rowText.TextAlignment = m_alignment; rowText.BackgroundColor = m_bgColor; //rowText.BackgroundColor = UIColor.Clear; rowText.TextColor = m_fontColor; view.AddSubview(rowText); } e.View = view.ToView(); }; m_picker.HeaderFontSize = m_picker.ColumnHeaderFontSize = m_picker.SelectedItemFontSize = m_picker.UnSelectedItemFontSize = 15; }