Bob Jones

Bob Jones

  • NA
  • 2
  • 720

Xamarin Forms Binding Source Question

Nov 27 2018 9:54 AM
Greetings - I am new to Xamarin Forms and am using C# as the backend.  I am wanting to create a grid that has a switch grid (what I like to call a toggle button) and 5 fields.  I need the data source of those 5 fields to be pulled from a sql server database.
 
I come from C# background so I am invisioning a datatable set-up that displays all rows that meet the criteria of my Select statement.  I have come up with this XAML which meets what I need, however I do not know how to Bind my data to the textboxes.
 
Can someone here assist me?
  1. <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"  
  2. xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"  
  3. x:Class="Test.Pages.TestApprove" >  
  4. <ContentPage.Content>  
  5. <StackLayout>  
  6. <Label Text="The users below are Requesting Access:"></Label>  
  7. <Grid Padding="5,0" RowSpacing="1" ColumnSpacing="1">  
  8. <Grid.RowDefinitions>  
  9. <RowDefinition Height="auto" />  
  10. </Grid.RowDefinitions>  
  11. <Grid.ColumnDefinitions>  
  12. <ColumnDefinition Width="*" />  
  13. <ColumnDefinition Width="*" />  
  14. <ColumnDefinition Width="*" />  
  15. <ColumnDefinition Width="auto" />  
  16. </Grid.ColumnDefinitions>  
  17. <Switch Grid.Row="0" Grid.Column="0" VerticalOptions="Center"  
  18. HorizontalOptions="Center" BackgroundColor="Brown" />  
  19. <Label Text="{Binding fname}" Grid.Row="0" Grid.Column="1"  
  20. Grid.ColumnSpan="1" Margin="1"  
  21. BackgroundColor="Blue" IsEnabled="false"/>  
  22. <Entry Text="{Binding lname}" Grid.Row="0" Grid.Column="2"  
  23. Grid.ColumnSpan="1" Margin="1" IsEnabled="false"  
  24. FontSize="Small" BackgroundColor="Purple" />  
  25. <Entry Text="{Binding company}" Grid.Row="0" Grid.Column="3"  
  26. Grid.ColumnSpan="1" Margin="1"  
  27. FontSize="Small" BackgroundColor="Green" />  
  28. <Entry Text="{Binding Phone}" Grid.Row="0" Grid.Column="4"  
  29. Grid.ColumnSpan="1" Margin="1"  
  30. FontSize="Small" BackgroundColor="Orange" />  
  31. </Grid>  
  32. <Button Command="{Binding ApproveUserCommand}" Text="Approve User" TextColor="White"  
  33. FontAttributes="Bold" FontSize="Large" HorizontalOptions="FillAndExpand"  
  34. BackgroundColor="#088da5" />  
  35. </StackLayout>  
  36. </ContentPage.Content>  
  37. </ContentPage>

Answers (1)