curtainrising curtainrising - 3 months ago 17x
iOS Question

C# Xamarin Visual Studios Use different kind of UIView to display information for UITextField.InputView

So I have been able to get a UIPickerView to work with this code. I am able to see the files in a picker when i click the textfield.

-filesInPath comes from a dropbox connection.

-AddClassDropboxPathTextBox is a textfield.

public override void ViewDidLoad(){
public void setupFilePicker(){
PickerModelmodel = new PickerModel(filesInPath);
UIPickerView picker = new UIPickerView();
picker.Model = model;

UIToolbar pickerToolbar = new UIToolbar();
pickerToolbar.BarStyle = UIBarStyle.Black;
pickerToolbar.Translucent = true;

UIBarButtonItem doneButton = new UIBarButtonItem("Choose", UIBarButtonItemStyle.Done, (s, e) => {
pickerToolbar.SetItems(new UIBarButtonItem[] { doneButton }, true);
AddClassDropboxPathTextBox.InputView = picker;
AddClassDropboxPathTextBox.InputAccessoryView = pickerToolbar;
public class PickerModel : UIPickerViewModel
public List<string> Items { get; private set; }
public Int32 SelectedIndex { get; set; }
public PickerModelSource(List<String> items)
SelectedIndex = 0;
tems = items;

My problem Is I don't want to use a picker. I want to use a UITableView, so I can allow the user to search through their dropbox file structure. I have tried to replace UIPickerViewModel with a UITableViewSource. When I click the textfield only the toolbar shows up, and I get no errors.

TableViewSource source = new PTableViewSource(filesInPath);
UITableView picker = new UITableView();
picker.Source = source;

My hope is someone can help me figure out a way to get a UITableView to work instead of UIPickerView.


So it turns out that Pickers generally come with a predefined space they take up, while UITableViews do not. So a solution is something like this. It should be noted that in the size only the y value really matters.

UITableView table = new UITableView(new CoreGraphics.CGRect(new CoreGraphics.CGPoint(0, 0), new CoreGraphics.CGSize(1, 100)));