1
votes

I'm newbie when it comes to xamarin, also in XAML, I just want to ask how to add a padding inside my viewcell below is my code

<TableView>
        <TableRoot>
            <TableSection Title = "Basic information">
                <EntryCell Label = "First name: " Placeholder = "Required" />
                <EntryCell Label = "Middel name: " Placeholder = "Optional" />
                <EntryCell Label = "Last name: " Placeholder = "Required" />
                <ViewCell>
                    <Picker x:Name="genderPicker" Title = "Select gender"></Picker>
                </ViewCell>
            </TableSection>
        </TableRoot>
</TableView>

what i want is to add a little bit padding inside of this code.

            ![<ViewCell>
                <Picker x:Name="genderPicker" Title = "Select gender"></Picker>
            </ViewCell>][1]

This is what it looks like, so i just want to add some left and right space on my picker view.

http://i.stack.imgur.com/89qt9.png

2

2 Answers

2
votes

Something like this should works fine:

  <Picker x:Name="genderPicker" 
  Title = "Select gender"
  Padding="left, top, right, bottom">
  </Picker>

With left,top,right and bottom the value you would like. More information here

1
votes

Add a StackLayout, or any other Layout subtype that supports padding, inside your ViewCell. You can then use the Layout properties to adjust the Picker.

<ViewCell>
  <StackLayout Padding="10,0,0,0" HorizontalOptions="FillAndExpand">
    <Picker HorizontalOptions="CenterAndExpand" >
      <Picker.Items>
        <x:String>Disabled</x:String>
        <x:String>5 minutes</x:String>
      </Picker.Items>
      <Picker.SelectedIndex>0</Picker.SelectedIndex>
    </Picker>  
  </StackLayout>
</ViewCell>

Unlike CSS or Android Views where you can tweak the controls themselves, you'll handle most of your padding using parent Layouts when working in Xamarin.Forms.