Xamarin.forms - Gridview row height error - xamarin

My ContentPage have a Grid inside a ListView that contains a column (x:Name="stlNomeMiniatura") with a label and an image, as below:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="InventarioBensCelular.MainPage"
BackgroundColor="White">
<ContentPage.Content>
<StackLayout>
<StackLayout Orientation="Vertical" VerticalOptions="Start" HeightRequest="130" Background="#003399">
<StackLayout Orientation="Horizontal" HorizontalOptions="Start" VerticalOptions="Start" HeightRequest="40" Margin="7,10">
<StackLayout Orientation="Horizontal">
<Image Source="Icone.png" Aspect="Fill" HeightRequest="40" WidthRequest="48" VerticalOptions="Center"
HorizontalOptions="Start"/>
</StackLayout>
<StackLayout Orientation="Horizontal" WidthRequest="300" HeightRequest="40">
<StackLayout Orientation="Vertical">
<Label x:Name="lblTitulo" Text="Inventário de Bens" FontSize="17" FontAttributes="Bold"
VerticalOptions="Start" TextColor="White" Padding="0,-2,0,0"/>
<Label x:Name="lblSubtitulo" Text="Transmissão de Foto" FontSize="17" FontAttributes="Bold"
VerticalOptions="Start" TextColor="White" Padding="0,-7,0,0"/>
</StackLayout>
</StackLayout>
<StackLayout Orientation="Horizontal" HorizontalOptions="EndAndExpand" VerticalOptions="Center" HeightRequest="40">
<ImageButton Source="ParametrosVerde.png" HorizontalOptions="Center" VerticalOptions="Center"
HeightRequest="32" WidthRequest="32" Clicked="Parametro_Clicou"/>
</StackLayout>
</StackLayout>
<StackLayout Orientation="Horizontal" HorizontalOptions="CenterAndExpand" VerticalOptions="Start">
<StackLayout WidthRequest="160" Margin="7,0">
<Frame x:Name="TiraFoto" CornerRadius="10" BorderColor="DarkGreen" HorizontalOptions="StartAndExpand"
Padding="0" HeightRequest="32" VerticalOptions="Start" BackgroundColor="#E0FFE0" WidthRequest="160">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="TiraFoto_Clicou" />
</Frame.GestureRecognizers>
<StackLayout Orientation="Horizontal" HorizontalOptions="StartAndExpand" Padding="10,0,0,0">
<Image Source="Camera.png" Aspect="Fill" HeightRequest="26" WidthRequest="24" VerticalOptions="Center" HorizontalOptions="Start"/>
<Label Text="Tirar Uma Foto" FontSize="16" FontAttributes="Bold" VerticalTextAlignment="Center" HorizontalOptions="Start"
TextColor="DarkGreen"/>
</StackLayout>
</Frame>
</StackLayout>
<StackLayout WidthRequest="160">
<Frame x:Name="Sair" CornerRadius="10" BorderColor="Red"
Padding="0" HeightRequest="32" VerticalOptions="Start" BackgroundColor="#FFE8E8" WidthRequest="160">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="Sair_Clicou" />
</Frame.GestureRecognizers>
<StackLayout Orientation="Horizontal" HorizontalOptions="StartAndExpand" Padding="10,0,0,0">
<Image Source="Sair.png" Aspect="Fill" HeightRequest="24" WidthRequest="24" VerticalOptions="Center" HorizontalOptions="Start"
IsAnimationPlaying="True"/>
<Label Text="Sair Programa" FontSize="16" FontAttributes="Bold" VerticalTextAlignment="Center" HorizontalOptions="Start"
TextColor="Red"/>
</StackLayout>
</Frame>
</StackLayout>
<StackLayout>
</StackLayout>
<StackLayout Margin="0,-2">
<Frame x:Name="WiFi" CornerRadius="10" BorderColor="#003399"
Padding="0" HeightRequest="35" VerticalOptions="Center" BackgroundColor="White" WidthRequest="35">
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="WiFi_Clicou" />
</Frame.GestureRecognizers>
<Image x:Name="imgWiFiStatus" Source="WifiVermelho.gif" Aspect="Fill" HeightRequest="24" WidthRequest="24"
VerticalOptions="Center" HorizontalOptions="Center"/>
</Frame>
</StackLayout>
</StackLayout>
</StackLayout>
<Frame BackgroundColor="Transparent" HeightRequest="25" Padding="0" VerticalOptions="Center" Margin="10,0">
<Label Text="Arquivos a Transmitir:" FontSize="15" FontAttributes="Bold"
VerticalOptions="Start" TextColor="#003399"/>
</Frame>
<StackLayout Margin="10,0" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<ListView x:Name="ltvArquivoLista" SeparatorVisibility="None" SelectionMode="None" HasUnevenRows="False" IsPullToRefreshEnabled = "True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid BackgroundColor="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="169"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="347"></ColumnDefinition>
<ColumnDefinition Width="40"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackLayout x:Name="stlNomeMiniatura" Grid.Row="0" Grid.Column="0" Orientation="Vertical"
HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand">
<Label Text="{Binding Nome, Mode=OneWay}" FontSize="15"
VerticalOptions="Start" TextColor="#003399"/>
<Image Source="{Binding Miniatura, Mode=OneWay}" Aspect="AspectFit"
VerticalOptions="Start"
HorizontalOptions="Start"/>
</StackLayout>
<StackLayout Grid.Row="0" Grid.Column="1" Orientation="Vertical"
HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand">
<Image x:Name="cmdExcluirFoto" Source="{Binding BotaoExcluirImagem, Mode=OneWay}" Aspect="AspectFill"
HeightRequest="32" WidthRequest="32" VerticalOptions="Start" HorizontalOptions="Start">
<Image.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="1" Tapped="Foto_Excluir_Clicou"/>
</Image.GestureRecognizers>
</Image>
</StackLayout>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</StackLayout>
</ContentPage.Content>
</ContentPage>
In the .CS file I have the following piece of code that shows how the ListView ItemsSource is set with the ObservableCollection "Arquivo":
public ObservableCollection<Arquivo> Arquivos = new ObservableCollection<Arquivo>();
private List<string> ArquivosATransmitir = null;
private DateTime TestaConexaoIntervaloDtInicio = Convert.ToDateTime("2000/01/01 00:00:00");
private DateTime TestaConexaoIntervaloDtFim = Convert.ToDateTime("2000/01/01 00:00:00");
public MainPage()
{
InitializeComponent();
DeviceInfo = new DeviceInfo.CDeviceInfo();
Rotinas.File_Found("Inventario.ini", DeviceInfo.Info.Application.DataFolder, false, #"/");
if (Rotinas.INIFileName == null)
{
Rotinas.INIFileName = DeviceInfo.Info.Application.DataFolder + #"/Inventario.ini";
Rotinas.INI_Write("[SISTEMA]", "Titulo", "Inventário de Bens");
Rotinas.INI_Write("[SISTEMA]", "Subtitulo", "Transmissão de Fotos");
Rotinas.INI_Write("[SERVIDOR]", "IP", "192.168.0.22");
Rotinas.INI_Write("[SERVIDOR]", "Porta", "1234");
}
TituloSistema = Rotinas.INI_Read("[SISTEMA]", "Titulo");
Subtitulo = Rotinas.INI_Read("[SISTEMA]", "Subtitulo");
ServidorIP = Rotinas.INI_Read("[SERVIDOR]", "IP");
if (ServidorIP != "")
{
string auxPorta = Rotinas.INI_Read("[SERVIDOR]", "Porta");
if (auxPorta != null)
{
ServidorPorta = auxPorta;
}
else
{
ServidorPorta = "1234";
}
} else
{
ServidorIP = null;
ServidorPorta = null;
}
this.lblTitulo.Text = TituloSistema;
this.lblSubtitulo.Text = Subtitulo;
ConexaoServidor = new Connection();
ConexaoServidor.FileTypeName = "Fotos";
DiretorioArquivosATransmitir = DeviceInfo.Info.Application.DataFolder + #"/ArquivosATransmitir";
if (!Directory.Exists(DiretorioArquivosATransmitir))
{
Directory.CreateDirectory(DiretorioArquivosATransmitir);
}
ArquivosATransmitir = Directory.GetFiles(DiretorioArquivosATransmitir, "*.*", SearchOption.AllDirectories)
.Where(file => new string[] { ".jpg" }.Contains(Path.GetExtension(file))).ToList();
if (ArquivosATransmitir.Count > 0)
{
for (int Ctr = 0; Ctr <= ArquivosATransmitir.Count - 1; Ctr++)
{
GridArquivo_Incluir(ArquivosATransmitir[Ctr]);
}
}
ltvArquivoLista.ItemsSource = Arquivos;
Testa_Conexao_Servidor();
}
I would like it to appear as below:
But, the GridView is shown with the rows height fixed with the images truncated, as below:
What am I doing wrong?
Thanks in advance, sorry for my poor English.
Marcelo Camarate

You can try to modify your code as follows:
1.change the value of property HasUnevenRows from False to True for your Listview (ltvArquivoLista)
HasUnevenRows="True"
2.change Height of RowDefinition from 169 to * or Auto;
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="347"></ColumnDefinition>
<ColumnDefinition Width="40"></ColumnDefinition>
</Grid.ColumnDefinitions>

Related

Programmatically modification of CarouselView

I have a CarouselView inside a ScrollView. To control the height I calculate it and modify it programmatically. It almost works, but the problem however is that it only works when the height is increased not when the height is decreased.
CarouselView
<CarouselView x:Name="cv" HeightRequest="8" ItemsSource="{Binding Challenge.ChallengeParts}" VerticalOptions="Center" ItemTemplate="{StaticResource ChallengePartTemplate}" Position="{Binding PageCarouselPosition}" Grid.Row="0" Grid.Column="1"></CarouselView>```
DataTemplate
<DataTemplate x:Key="ChallengePartTemplate">
<StackLayout BackgroundColor="LimeGreen" VerticalOptions="Center">
<Grid x:Name="rulesGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="20" />
</Grid.ColumnDefinitions>
<StackLayout x:Name="toggleShowRules" Grid.Column="0" Grid.Row="0">
<Label x:Name="showRulesText" Text="Vis regler fra video" FontAttributes="Bold" Grid.Column="0" Grid.Row="0" />
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Command="{Binding Source={x:Reference thisPage}, Path=BindingContext.ToggleShowRulesTappedCommand}" />
</StackLayout.GestureRecognizers>
</StackLayout>
<Label Text="{Binding Source={x:Reference thisPage}, Path=BindingContext.ShowRules,Converter={StaticResource CaretConverter}}" FontFamily="{StaticResource FontAwesomeSolid}" Grid.Column="1" Grid.Row="0" HorizontalTextAlignment="End" />
</Grid>
<StackLayout x:Name="showRulesStack" IsVisible="{Binding Source={x:Reference thisPage}, Path=BindingContext.ShowRules}">
<Grid Margin="20, 0, 0, 0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<!--Antal spillere-->
<StackLayout Orientation="Horizontal" Grid.Column="0" Grid.Row="0">
<Label Text="" FontFamily="{StaticResource FontAwesomeSolid}" FontSize="30" />
<Label Text="" FontFamily="{StaticResource FontAwesomeSolid}" FontSize="30" />
</StackLayout>
<StackLayout x:Name="numPlayersText" Spacing="0" Grid.Column="1" Grid.Row="0">
<Label Text="Antal spillere:" FontAttributes="Bold" FontSize="Micro" />
<Label Text="{Binding NumPlayers}" FontSize="Micro" />
</StackLayout>
<!--Nødvendigt udstyr-->
<StackLayout Orientation="Horizontal" Grid.Column="0" Grid.Row="1">
<Label Text="" FontFamily="{StaticResource FontAwesomeSolid}" FontSize="30" />
</StackLayout>
<StackLayout Spacing="0" Grid.Column="1" Grid.Row="1">
<Label Text="Nødvendigt udstyr:" FontAttributes="Bold" FontSize="Micro" />
<StackLayout BindableLayout.ItemsSource="{Binding NeededAccesories}" Spacing="0">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Label Text="{Binding .}" FontSize="Micro" />
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
</StackLayout>
<!--Regler-->
<StackLayout Orientation="Horizontal" Grid.Column="0" Grid.Row="2">
<Label Text="" FontFamily="{StaticResource FontAwesomeSolid}" FontSize="30" />
</StackLayout>
<StackLayout Grid.Column="1" Grid.Row="2">
<Label Text="Regler:" FontAttributes="Bold" FontSize="Micro" />
<StackLayout BindableLayout.ItemsSource="{Binding Rules}" Spacing="0">
<BindableLayout.ItemTemplate>
<DataTemplate>
<Label Text="{Binding .}" FontSize="Micro" />
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
</StackLayout>
</Grid>
</StackLayout>
</StackLayout>
</DataTemplate>
Code behind
var cvVisibleViews = cv.VisibleViews;
if(cvVisibleViews.Count > 0)
{
var rulesStack = cvVisibleViews[0].FindByName<StackLayout>("showRulesStack");
var toggleShowRules = cvVisibleViews[0].FindByName<StackLayout>("toggleShowRules");
var showRulesText = cvVisibleViews[0].FindByName<Label>("showRulesText");
double height = 0;
height = height + toggleShowRules.Height;
height = height + showRulesText.Height;
if (rulesStack.IsVisible && rulesStack.Height > -1)
{
height = height + rulesStack.Height;
}
cv.HeightRequest = height;
}
It seems like the new height of the CarouselView is measured from the center of it. Like the content is placed outside above the CarouselView
Any idea to realign the content inside the resized CarouselView?
Thanks a lot!

Xamarin Android CarouselView with IndicatorView position below the image

How can i put the indicatorview below and center of the image?
https://imgur.com/Wa3Ur48
I tried position and other stuff but i can't seem to move the indicatorview below the image.
<StackLayout Grid.Row="0" Orientation="Horizontal" VerticalOptions="Start" HorizontalOptions="FillAndExpand">
<!--<ffimageloading:CachedImage HorizontalOptions="Start" VerticalOptions="CenterAndExpand" Margin="10"
Style="{StaticResource RetailHeaderImage}"
Source="{Binding ImageSource}">
</ffimageloading:CachedImage>-->
<CarouselView ItemsSource="{Binding ImageUrls}" IndicatorView="indicatorView" HorizontalOptions="Start" VerticalOptions="CenterAndExpand" Margin="10" HeightRequest="150" WidthRequest="150" >
<CarouselView.ItemTemplate>
<DataTemplate>
<Grid
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand">
<ffimageloading:CachedImage
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand"
LoadingPlaceholder="loading.gif"
Aspect="AspectFill"
BackgroundColor="Black"
Source="{Binding}">
</ffimageloading:CachedImage>
</Grid>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
<IndicatorView x:Name="indicatorView"
IndicatorColor="LightGray"
SelectedIndicatorColor="DarkGray"
HorizontalOptions="StartAndExpand"
VerticalOptions="End"/>
<Label Text="{Binding ReferenceSku.Name}" Style="{StaticResource RetailHeaderText}" HorizontalOptions="FillAndExpand" LineBreakMode="WordWrap"/>
</StackLayout>
Set the Orientation of the StackLayout to Vertical. And then set the IndicatorView in the center of the StackLayout.
Refer to the xaml below:
<StackLayout Orientation="Vertical" VerticalOptions="Start" HorizontalOptions="FillAndExpand">
<!--<ffimageloading:CachedImage HorizontalOptions="Start" VerticalOptions="CenterAndExpand" Margin="10"
Style="{StaticResource RetailHeaderImage}"
Source="{Binding ImageSource}">
</ffimageloading:CachedImage>-->
<CarouselView ItemsSource="{Binding ImageUrls}" IndicatorView="indicatorView" HorizontalOptions="Start" VerticalOptions="CenterAndExpand" Margin="10" HeightRequest="150" WidthRequest="150" >
<CarouselView.ItemTemplate>
<DataTemplate>
<Grid
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand">
<Image Source="{Binding image}"></Image>
</Grid>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
<IndicatorView x:Name="indicatorView"
IndicatorColor="LightGray"
SelectedIndicatorColor="DarkGray"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand"/>
<Label Text="Name" LineBreakMode="WordWrap"/>
</StackLayout>

Changing BackgroundColor of Button within Xamarin CollectionView changes the BackgroundColor of every 8th button down. why?

I have a Xamarin CollectionView That uses a Button (Button x:Name="PNameButton") to Change the Background color of the button.
When the Button is clicked the background color changes... However - So does every 8th Button in the CollectionView. Its as if the CollectionView renders new data every 8 or so items, and that new first button gets the changed color property. How do I fix this? Code Follows:
<CollectionView x:Name="PairingsCollectionView" SelectionMode="Multiple" Margin="20,5,20,5" >
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Margin="0" Padding="0,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="25" />
<RowDefinition Height="35" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<BoxView Grid.Column="0" Grid.Row="0" Margin="0" Color="#333130"/>
<Button x:Name="PNameButton" Margin="0" Padding="0,0,0,0" Grid.Column="0" BackgroundColor="{Binding UseColor}" Text="{Binding PDisplayName}" FontSize="Small" TextColor="Black"
HorizontalOptions="Start" VerticalOptions="Center" Clicked="Button_Clicked" />
<BoxView Grid.Column="1" Grid.Row="0" Color="#333130" Margin="0"></BoxView>
<Label Margin="0" Padding="0,0,0,0" Grid.Column="1" TextColor="White" FontSize="Small"
HorizontalOptions="Center" VerticalOptions="Center" >
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding PDays, StringFormat='{0}Dy'}"/>
<Span Text=" "/>
<Span Text="{Binding PDay}"/>
</FormattedString>
</Label.FormattedText>
</Label>
<BoxView Grid.Row="0" Grid.Column="2" Margin="0" Color="#333130"></BoxView>
<Label Margin="0" Padding="0,0,0,0" Grid.Column="2" Text="{Binding PCredit, StringFormat='{0}'}" TextColor="#F57BFA" FontSize="Small"
HorizontalOptions="Center" VerticalOptions="Center"/>
<BoxView Grid.Row="0" Grid.Column="3" Color="#333130" Margin="0"></BoxView>
<Label Margin="0" Padding="0,0,0,0" Grid.Column="3" Text="{Binding PFlightTime, StringFormat='{0}'}" TextColor="White" FontSize="Small"
HorizontalOptions="Center" VerticalOptions="Center"/>
<BoxView Grid.Row="0" Grid.Column="4" Color="#333130" Margin="0"/>
<Label Margin="0" Padding="0,0,0,0" Grid.Column="4" Text="{Binding PRegionType, StringFormat='{0}'}" TextColor="White" FontSize="Small" HorizontalOptions="Center" VerticalOptions="Center"/>
<BoxView Grid.Row="0" Grid.Column="5" Color="#333130" Margin="0"/>
<CheckBox x:Name="IsSelectedCheckbox" Grid.Row="0" Grid.Column="5" IsChecked="{Binding PIsSelected}" VerticalOptions="Center"/>
<BoxView Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="1" Color="LightGray"></BoxView>
<Label Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="1" Text="{Binding PDateModified}" TextColor="Black" FontSize="Small"
HorizontalOptions="Center" VerticalOptions="Center"/>
<BoxView Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="5" Color="LightGray" ></BoxView>
<Label Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="5" Text="{Binding PLayovers}"
TextColor="Coral" FontAttributes="Bold" FontSize="17" HorizontalOptions="Start" VerticalOptions="Center" Margin="5,0,0,0" />
<WebView Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="6" BackgroundColor="#333130"
MinimumHeightRequest="150" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
HeightRequest="{Binding PWebViewHeight}" >
<WebView.Source>
<HtmlWebViewSource Html="{Binding PAllText}"/>
</WebView.Source>
</WebView>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
And in the Code Behind:
private void Button_Clicked(object sender, EventArgs e)
{
try
{
string ChkVal = "";
bool compareBool = false;
bool currentState = false;
Color buttonColer;
string ColorHexVal;
int i = 0;
var thisButton = sender as Button;
buttonColer = thisButton.BackgroundColor;
ColorHexVal = buttonColer.ToHex();
if (buttonColer != Color.FromHex("#F7F75A"))
{
currentState = true;
}
else
{
currentState = false;
}
var PairingItem = ((Button)sender).Parent.BindingContext as Pairings;
compareBool = App.DatabaseNA.GetIsSelected(PairingItem.PID);
if (!compareBool == true)
{
thisButton.BackgroundColor = Color.FromHex("#46AE3C");
}
else
{
thisButton.BackgroundColor = Color.FromHex("#F7F75A");
}
}
catch (Exception ex)
{
DisplayAlert("Alert", ex.InnerException.ToString(), "OK"); //await
}
}
Again - Thank You!!!
The code works great and sets the Background color of the button... The problem is - It sets the Background Color of every Button about 8 items down.
Thanks

Why does my IsVisible Binding Not Work with a StackLayout ? Xamarin iOS

I have the below XAML structure using a collection view which is using a list called 'users' as its ItemSource. I have a bound property which controls if the items are visible or not :
<StackLayout Orientation="Horizontal">
<Frame IsVisible="{Binding isVisible}" HasShadow="True" BackgroundColor="White" Padding="0">
The issue is that unless I remove the StackLayout around the Frame then the IsVisible binding doesn't work. Does anyone know why the binding works without the StackLayout, but not with ?
<CollectionView Grid.Row="1" x:Name="users" IsGrouped="True" SelectionMode="Single">
<CollectionView.GroupHeaderTemplate>
<DataTemplate>
<StackLayout Orientation="Horizontal" MinimumHeightRequest="200" BackgroundColor="{Binding tint_colour}">
<Image Source="{Binding school_image}" WidthRequest="120" HeightRequest="100"/>
<Label Text="{Binding organisation_title}"
TextColor="{Binding font_colour}"
FontSize="Large"
FontAttributes="Bold"
VerticalTextAlignment="Center"></Label>
<StackLayout.GestureRecognizers>
<TapGestureRecognizer Tapped="HeaderTapped" CommandParameter="{Binding organisation_title}"></TapGestureRecognizer>
</StackLayout.GestureRecognizers>
</StackLayout>
</DataTemplate>
</CollectionView.GroupHeaderTemplate>
<CollectionView.ItemsLayout>
<LinearItemsLayout Orientation="Vertical" ItemSpacing="1"/>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout Orientation="Horizontal">
<Frame IsVisible="{Binding isVisible}" HasShadow="True" BackgroundColor="White" Padding="0">
<Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<behaviors:Expander x:Name="MainExpander" CollapseAnimationLength="500" IsExpanded="False" IsVisible="True" >
<behaviors:Expander.Header>
<Grid HorizontalOptions="FillAndExpand">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="10"/>
</Grid.ColumnDefinitions>
<Frame HeightRequest="40" WidthRequest="40" CornerRadius="20" HorizontalOptions="Start" VerticalOptions="Center" Margin="20" Padding="0" BackgroundColor="Maroon">
<Label Text="{Binding student_initial}" TextColor="White" HorizontalOptions="Center" VerticalOptions="Center" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" />
</Frame>
<StackLayout Grid.Column="2" HorizontalOptions="StartAndExpand" VerticalOptions="Center" Margin="20">
<Label IsVisible="{Binding isVisible}" x:Name="StudentName" Text="{Binding student_fullname}"></Label>
<Label x:Name="StudentID" IsVisible="false" Text="{Binding student_unique_id}"></Label>
</StackLayout>
</Grid>
</behaviors:Expander.Header>
<Grid RowSpacing="0" HorizontalOptions="FillAndExpand" HeightRequest="240" VerticalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Grid.Row="0" Text="Messages" Clicked="Button_Clicked"></Button>
<Button x:Name="btnTopUp" Grid.Row="1" Text="Quick Topup" Clicked="Button_Clicked" IsVisible="{Binding topup_product_id, Converter={StaticResource IsNotNullOrEmptyConverter}}"></Button>
<Button Grid.Row="2" Text="Payments" Clicked="Button_Clicked"></Button>
</Grid>
<!-- TODO: Look at adding a balance for childrens topups? -->
</behaviors:Expander>
</Grid>
</Frame>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
I did a test about it and it works fine, here are xaml and codebehind:
xmal:
<StackLayout>
<CollectionView x:Name="mycol">
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout >
<Frame BackgroundColor="Red" IsVisible="{Binding isvisible}">
<Label Text="{Binding Name}"/>
</Frame>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
codebehind:
public partial class CollectionTest : ContentPage
{
ObservableCollection<People> peoples = new ObservableCollection<People> {
new People{ Name="Adam",isvisible=true},
new People{ Name="Bob",isvisible=true},
new People {Name="Adam2",isvisible=false },
new People{ Name="Bob2",isvisible=true} };
public CollectionTest()
{
InitializeComponent();
mycol.ItemsSource = peoples;
}

Cancel automatic focus on entry using xamarin telerik popup

I'm using a Telerik RadPopup composed with an entry and checkbox's.
When I open the popup, the focus is directly is the entry. But I dont want a focus in any component.
It is possible using this type of popup ?
There is the code
<telerikPrimitives:RadPopup.Popup>
<telerikPrimitives:RadPopup Placement="Center" IsModal="False" OutsideBackgroundColor="#6F000000" IsOpen="{Binding WantSendEmail}">
<telerikPrimitives:RadBorder CornerRadius="8" BackgroundColor="{StaticResource Key=LightBackgroundColor}">
<Frame HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" Padding="0" Margin="0" WidthRequest="250">
<StackLayout Orientation="Vertical" >
<StackLayout BackgroundColor="{StaticResource Key=MainButtonPrimaryColor}"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<Label Text="Envoi par Email" HorizontalOptions="CenterAndExpand" FontSize="{Binding FontSizeXSmall}"
Padding="10"
TextColor="White" VerticalOptions="CenterAndExpand"/>
</StackLayout>
<StackLayout Orientation="Horizontal" Padding="10,10,10,0"
HorizontalOptions="StartAndExpand" VerticalOptions="CenterAndExpand">
<CheckBox IsChecked="{Binding SaisieLibre, Converter={StaticResource cnvInverseBoolConverter}}" Color="{StaticResource Key=MainButtonPrimaryColor}"/>
<ContentView Focused="ContentView_Focused" Content="{Binding EntrySearchTiers}" Padding="10,10,10,0"
IsEnabled="{Binding SaisieLibre, Converter={StaticResource cnvInverseBoolConverter}}"/>
</StackLayout>
<StackLayout Orientation="Horizontal" Padding="10,10,10,0"
HorizontalOptions="StartAndExpand" VerticalOptions="CenterAndExpand">
<CheckBox IsChecked="{Binding SaisieLibre}" Color="{StaticResource Key=MainButtonPrimaryColor}"/>
<Label Text="Saisie Libre" VerticalOptions="CenterAndExpand"/>
</StackLayout>
<StackLayout Orientation="Horizontal" Padding="10,10,10,0"
HorizontalOptions="StartAndExpand" VerticalOptions="CenterAndExpand"
IsEnabled="{Binding CurrentUserHasContact}">
<CheckBox IsChecked="{Binding CCEnable}" Color="{StaticResource Key=MainButtonPrimaryColor}"/>
<Label Text="Recevoir une copie" VerticalOptions="CenterAndExpand"/>
</StackLayout>
<StackLayout Padding="10,0,10,10">
<Button Style="{StaticResource Key=BtnFlex}" Text="Envoyer"
WidthRequest="100" HeightRequest="30"
Command="{Binding SendMailCommand}"/>
</StackLayout>
</StackLayout>
</Frame>
</telerikPrimitives:RadBorder>
</telerikPrimitives:RadPopup>
</telerikPrimitives:RadPopup.Popup>
And the contentView :
EntrySearchTiers = new SearchableEntry()
{
Style = (Xamarin.Forms.Style)Application.Current.Resources["MainEntryStyle"],
FontSize = FontSizeMedium,
Placeholder = "Liste des tiers"
};
EntrySearchTiers.Behaviors.Add(new Prism.Behaviors.EventToCommandBehavior
{
//EventName = "Completed", --> Jamais triggered
EventName = "TextChanged",
Command = TiersSelectedCommand
});
EntrySearchTiers.SetBinding(Entry.TextProperty, new Binding("CodeTiersSelected", BindingMode.TwoWay, null));
Base.Views.Popups.ChoicesPopup popup = new Base.Views.Popups.ChoicesPopup(_serviceTiers, null, Guid.Empty, EntrySearchTiers, "code tiers :", this, serviceHistoChoice: _serviceHistoChoice, groupChoice: Enums.enumGroupChoice.Tiers);
await popup.ActivateSearchEntryBehavior();
enter code here

Resources