See this image
Mylayoutisbroken.Youcanseethatthecustomernameis:SebastiaoLoureirodeAlmeidaandinthelistviewSebastiaoappearsandtherestofthenameappearsbelow,appearingonlythe" of the name "iceberg". My difficulty is in increasing the cell size or a horizontal scroll. I tried scrolling, putting the entire stacklayout in, but it did not work. See the mainpage xaml:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Autorizador"
x:Class="Autorizador.MainPage">
<StackLayout Orientation="Vertical">
<StackLayout Padding="5,5,0,0">
<Label Text="Adicionar um Produto" TextColor="Green" />
</StackLayout>
<StackLayout Padding="10,0,10,0">
<Label x:Name="txtNome" Text="Cliente" HorizontalOptions="Start"
VerticalOptions="StartAndExpand" HeightRequest="20" WidthRequest="300" FontSize="Small"/>
<Label x:Name="txtCategoria" Text="Vendedor" HorizontalOptions="Start" VerticalOptions="StartAndExpand"
HeightRequest="20" WidthRequest="300" FontSize="Small"/>
<Label x:Name="txtPreco" Text="Juros" HorizontalOptions="Start" VerticalOptions="StartAndExpand"
HeightRequest="20" WidthRequest="300" FontSize="Small" />
<!--<Button HorizontalOptions="FillAndExpand" VerticalOptions="StartAndExpand" HeightRequest="40" Text="Adicionar/Atualizar Produto"
Clicked="btnAdicionar_Clicked" FontSize="Small"/>-->
</StackLayout>
<ScrollView HorizontalOptions="FillAndExpand">
<StackLayout Orientation="Vertical" Padding="10,5,10,0">
<ListView x:Name="listaLibera" ItemSelected="listaLibera_ItemSelected" BackgroundColor="Aqua" SeparatorColor="Blue">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<!--<ViewCell.ContextActions>
<MenuItem Clicked="OnAtualizar" CommandParameter="{Binding .}" Text="Atualizar" />
<MenuItem Clicked="OnDeletar" CommandParameter="{Binding .}" Text="Deletar" IsDestructive="True" />
</ViewCell.ContextActions>-->
<StackLayout Padding="10,10" Orientation="Horizontal" HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand">
<Label Text="{Binding Cliente}" HorizontalOptions="StartAndExpand"/>
<Label Text="{Binding Vendedor}" TextColor="Blue" HorizontalOptions="Center"/>
<Label Text="{Binding Juros}" HorizontalOptions="End"/>
<Label Text="{Binding Filial}" HorizontalOptions="End" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ScrollView>
</StackLayout>
</ContentPage>
The Mainpage C #
public partial class MainPage : ContentPage
{
DataService dataService;
List<Liberacao> libera;
public MainPage()
{
InitializeComponent();
dataService = new DataService();
AtualizaDados();
}
async void AtualizaDados()
{
libera = await dataService.GetLiberaAsync();
listaLibera.ItemsSource = libera.OrderBy(item => item.Cliente).ToList();
}
private bool Valida()
{
if (string.IsNullOrEmpty(txtNome.Text) && string.IsNullOrEmpty(txtCategoria.Text) && string.IsNullOrEmpty(txtPreco.Text))
{
return false;
}
else
{
return true;
}
}
private void listaLibera_ItemSelected(object sender, SelectedItemChangedEventArgs e)
{
var libera = e.SelectedItem as Liberacao;
txtNome.Text = "Cliente: " + libera.Cliente;
txtCategoria.Text = "Vendedor: " + libera.Vendedor;
txtPreco.Text = "Juros: " + libera.Juros.ToString();
}
}