I am using version 16.1.0.37 of the Xamarin Forms Controls.
I have been struggling to get the SfDataForm control to display editors in a linear layout all week.
Below is the code snippet I'm trying to display.
<ContentPage.Content>
<ScrollView>
<Grid Margin="3,5">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<dataForm:SfDataForm x:Name="dataForm" Grid.Row="0" VerticalOptions="Start" HorizontalOptions="Start" Margin="0"
LabelPosition="Top" ColumnCount="1" CommitMode="PropertyChanged" ValidationMode="PropertyChanged"/>
<controls:RoundButtonView Grid.Row="1" Margin="0,2" Color="#00D59F" BorderColor="#00D59F" BorderWidth="1" CornerRadius="24"
HorizontalOptions="Center" VerticalOptions="Center" OnClick="SaveForm"
HeightRequest="45" WidthRequest="250" ShapeType="Box">
<Label Text="Save" FontSize="20" TextColor="White" VerticalOptions="Center" HorizontalOptions="Center" VerticalTextAlignment="Center" HorizontalTextAlignment="Center"></Label>
</controls:RoundButtonView>
</Grid>
</ScrollView>
</ContentPage.Content>
The form renders the labels and the editors too far apart when the page loads.
The attachment contains screenshots of what the render looks like.
The spacing between the labels and the editors is just too much and makes the form completely unusable.
Note that this only happens when the LabelPosition is set to Top, when it is set to Left, the form renders the labels
and editors close enough as expected.
I just need the labels to be rendered on top of the editors.
Also, I have been having too many problems with the SfDataGrid.
Databinding appears to be an issue with this datagrid control.
When you bind from code, it does not render. If it does render, I typically have to figure out why.
When you bind from Xaml, it either does not render or throws too many exceptions that cannot be debugged.
<ContentView.BindingContext>
<vm:IncomeBudgetsViewModel x:Name="ViewModel"></vm:IncomeBudgetsViewModel>
</ContentView.BindingContext>
<ContentView.Content>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<ScrollView Grid.Row="0">
<StackLayout Orientation="Vertical" Spacing="4" Margin="0" Padding="0">
<sfgrid:SfDataGrid x:Name="dataGrid" ItemsSource="{Binding DataList}" AllowLoadMore="True"
LoadMoreCommand="{Binding LoadMoreCommand}" AllowPullToRefresh="True" PullToRefreshCommand="{Binding RefreshCommand}"
AllowEditing="False" CurrentCellBeginEdit="CurrentCellBeginEdit" CurrentCellEndEdit="CurrentCellEndEdit" SelectionChanged="OnGridSelected"
AllowResizingColumn="True" AutoGenerateColumns="false" AllowSorting="True" AllowMultiSorting="True"
AllowSwiping="True" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
SelectionMode="Single" ColumnSizer="Star" VerticalOverScrollMode="None" Margin="0,0,0,0" Padding="0,0,0,5">
<sfgrid:SfDataGrid.Columns>
<sfgrid:GridPickerColumn BindingContext="{x:Reference ViewModel}"
MappingName="IncomeCategoryKey" ItemsSource="{Binding IncomeCategories}" DisplayMemberPath="Name" ValueMemberPath="Id"
HeaderFontAttribute="Bold" HeaderText="Category">
</sfgrid:GridPickerColumn>
<sfgrid:GridNumericColumn MappingName="Target" HeaderText="Target" Format="N" TextWrapping="NoWrap" HeaderFontAttribute="Bold"></sfgrid:GridNumericColumn>
</sfgrid:SfDataGrid.Columns>
</sfgrid:SfDataGrid>
</StackLayout>
</ScrollView>
</Grid>
</ContentView.Content>
The code below shows where the ContentView containing the grid is passed data from a parent view to render.
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class CVGridIncomeBudgets : ContentView
{
public CVGridIncomeBudgets()
{
InitializeComponent();
//ViewModel = new IncomeBudgetsViewModel();
//dataGrid.ItemsSource = ViewModel.DataList;
//BindingContext = ViewModel;
}
//IncomeBudgetsViewModel ViewModel
//{
// get; set;
//}
BudgetPlansMasterView CurrentBudgetPlan
{
get; set;
}
public void LoadData(BudgetPlansMasterView plan)
{
UserDialogs.Instance.Alert($"total budgets found b4->{ViewModel.DataList.Count}", "Totals", "Ok");
if (!ViewModel.IsDataLoaded)
{
CurrentBudgetPlan = plan;
ViewModel.CurrentBudgetPlan = plan;
ViewModel.LoadMoreCommand.Execute(null);
// dataGrid.PullToRefreshCommand.Execute(null);
}
UserDialogs.Instance.Alert($"total budgets found after->{ViewModel.DataList.Count}", "Totals", "Ok");
}
The datagrid simply does not render any data, but shows up with a blank datagrid and no rows at all.
What could be wrong? I'm presenting this demo on Monday and I need this to work.
Please respond asap.
Thanks,
Ozioma