I am trying to hightlight selected item of collectionview with different color. The code works fine in iOS, but in Android it doesn't work. In Android, the first item is always selected but it doesn't hightlight the other items when I click them.
Update
I found the issue is GestureRecognizers on the Grid, If I remove that. It behavious as expected. After adding GestureRecognizers, the expected behavior is lost.
Workaround
If I wrap the Grid inside SwipeView, it works fine. However, the problem still remain when CollectionView has more than 100 items.
2nd Workaround
This worked nicely for any number of items in the CollectionView. Add second Grid inside the 1st Grid and apply GestureRecognizers event on the 2nd Grid and everythings works smoothly and as expected.
Theme.xaml -> getting styles from the theme file
<Style TargetType="Grid" x:Key="ItemTemplateGrid">
<Setter Property="VisualStateManager.VisualStateGroups">
<VisualStateGroupList>
<VisualStateGroup>
<VisualState Name="Normal"/>
<VisualState Name="Selected">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="{AppThemeBinding Dark={StaticResource BackgroundSecondaryColorDark}, Light={StaticResource BackgroundSecondaryColorLight}}"/>
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateGroupList>
</Setter>
</Style>
XAML Page Resource
<DataTemplate x:Key="AndroidAyaItemTemplate">
<Grid RowDefinitions="*,Auto" Style="{DynamicResource ItemTemplateGrid}">
<Grid Grid.Row="0" RowDefinitions="Auto,Auto,Auto" RowSpacing="0" Padding="10">
<Label Grid.Row="0" LineBreakMode="WordWrap" IsVisible="{Binding BindingContext.ShowEnglishVerseNumber,
Source={x:Reference MyPage}, Converter={StaticResource InverterBooleanConverter}}">
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding ArabicText.Aya}" FontSize="{Binding BindingContext.ActiveArabicFont.FontSize, Source={x:Reference MyPage}}"
FontFamily="{Binding BindingContext.ActiveArabicFont.FontPath, Source={x:Reference MyPage}}"/>
<Span Text="{Binding ArabicText.ArabicAyaNumber, StringFormat='﴿{0}﴾'}"
FontSize="{Binding BindingContext.ActiveArabicFont.FontSize, Source={x:Reference MyPage}}"
FontFamily="Sherzad"></Span>
</FormattedString>
</Label.FormattedText>
</Label>
<Label Grid.Row="0" LineBreakMode="WordWrap" IsVisible="{Binding BindingContext.ShowEnglishVerseNumber, Source={x:Reference MyPage}}">
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding ArabicText.Aya}" FontSize="{Binding BindingContext.ActiveArabicFont.FontSize, Source={x:Reference MyPage}}"
FontFamily="{Binding BindingContext.ActiveArabicFont.FontPath, Source={x:Reference MyPage}}"/>
<Span Text="﴿" FontSize="35" FontFamily="Sherzad"></Span>
<Span Text="{Binding ArabicText.AyaNumber, Converter={StaticResource ZeroToEmptyConverter}}" FontSize="Small"></Span>
<Span Text="﴾" FontSize="35" FontFamily="Sherzad"></Span>
</FormattedString>
</Label.FormattedText>
</Label>
<Label Grid.Row="1" LineBreakMode="WordWrap" HorizontalTextAlignment="Start" Margin="0,5,0,5"
IsVisible="{Binding BindingContext.ShowTransliteration, Source={x:Reference MyPage}}"
FontSize="{Binding BindingContext.TransliterationFontSize, Source={x:Reference MyPage}}"
Text="{Binding ArabicText.Transliteration}"
FlowDirection="LeftToRight">
</Label>
<Label Grid.Row="2" LineBreakMode="WordWrap" HorizontalTextAlignment="Start"
IsVisible ="{Binding BindingContext.TranslationVisible, Source={x:Reference MyPage}}"
FontSize="{Binding BindingContext.ActiveTranslationFont.FontSize, Source={x:Reference MyPage}}"
FontFamily="{Binding BindingContext.ActiveTranslationFont.FontPath, Source={x:Reference MyPage}}"
Text="{Binding AyaTranslation}"
FlowDirection="{Binding BindingContext.ActiveTranslationLanguage.FlowDirection, Source={x:Reference MyPage}}"/>
</Grid>
<BoxView Grid.Row="1" Style="{DynamicResource HLine}" IsVisible="{Binding BindingContext.ShowHorizentalLine, Source={x:Reference MyPage}}"/>
<Grid.GestureRecognizers>
<TapGestureRecognizer NumberOfTapsRequired="2" Command="{Binding BindingContext.ShareAyaCommand,Source={x:Reference itemView}}" CommandParameter="{Binding .}"/>
<SwipeGestureRecognizer Direction="Right" Command="{Binding BindingContext.NextChapterCommand, Source={x:Reference MyPage}}"/>
<SwipeGestureRecognizer Direction="Left" Command="{Binding BindingContext.PreviousChapterCommand, Source={x:Reference MyPage}}"/>
</Grid.GestureRecognizers>
</Grid>
</DataTemplate>
CollectionView
<CollectionView Grid.Row="0" ItemsSource="{Binding ArabicListText}" SelectedItem="{Binding SelectedAya}" SelectionMode="Single" FlowDirection="RightToLeft"
ItemTemplate="{StaticResource AndroidAyaItemTemplate}"
x:Name="itemView">
<CollectionView.ItemsLayout>
<LinearItemsLayout Orientation="Vertical" ItemSpacing="5"/>
</CollectionView.ItemsLayout>
</CollectionView>
If I remove the style "ItemTemplateGrid" from the Grid, it highlights every row accordingly, but the color is the default color of OS.
There is no need for SwipeView. It should work without boths workarounds.
Since you had used the SelectedItem="{Binding SelectedAya}" , you could define a property in the model which bind the backgroundcolor of the DataTemplate so that you don't need to use style dictionary any more .
in your model
Add a property
private Color bgColor;
public Color BgColor
{
get => bgColor;
set
{
if (bgColor!= value)
{
bgColor= value;
foreach(YourModel model in ArabicListText)
{
if(mdoel == SelectedAya)
{
if(App.Current.RequestedTheme== OSAppTheme.Dark)
{
model.BgColor = xxx;
}
else
{
model.BgColor = xxx;
}
}
else
{
model.BgColor = xxx;
}
}
OnPropertyChanged(nameof(BgColor));
}
}
}
in DataTemplate
<Grid RowDefinitions="*,Auto" BackgroundColor="{Binding BgColor}" Padding="10">
in Code Behind(ViewModel)
private YourModel selectedAya;
public YourModel SelectedAya
{
get => selectedAya;
set
{
if (selectedAya!= value)
{
selectedAya= value;
OnPropertyChanged(nameof(SelectedAya));
}
}
}
Related
I'm learning xamarin and all my attempts to influence the behavior of my label have failed. only my label still behaves strangely how to right align screen.
They do not change even if I put horizontalOptions everywhere, it seems to me that I just don’t know something
my ProductCard
<Grid xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:models="clr-namespace:Notes.Models;assembly=Notes"
x:DataType="models:Goods"
x:Class="Notes.Cells.ProductCard">
<Frame Style="{StaticResource ProductCard}" BackgroundColor="Coral">
<StackLayout Orientation="Horizontal">
<StackLayout VerticalOptions="Center">
<Label
BackgroundColor="Aqua"
HorizontalTextAlignment="End"
VerticalOptions="End"
HorizontalOptions="End">
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding Name}" Style="{StaticResource LabelMedium}" BackgroundColor="Blue"></Span>
<Span Text=" " BackgroundColor ="Brown"/>
<Span Text="Price: " BackgroundColor="Green"/>
<Span Text="{Binding Price}" FontAttributes="Bold" BackgroundColor="Yellow"/>
</FormattedString>
</Label.FormattedText>
</Label>
</StackLayout>
</StackLayout>
</Frame>
and my ListView
<?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:viewmodels="clr-namespace:Notes.ViewModel"
xmlns:cells="clr-namespace:Notes.Cells"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
x:DataType="viewmodels:GoodsViewModel"
x:Class="Notes.Views.ProductsCatalog"
>
<ContentPage.BindingContext>
<viewmodels:GoodsViewModel />
</ContentPage.BindingContext>
<ContentPage.Resources>
<ResourceDictionary>
<DataTemplate x:Key="Normal">
<ViewCell>
<cells:ProductCard/>
</ViewCell>
</DataTemplate>
<DataTemplate x:Key="Special">
<ViewCell>
<cells:SpecialItem/>
</ViewCell>
</DataTemplate>
<cells:ItemDataTemplateSelector x:Key="GoodsSelector"
Normal="{StaticResource Normal}"
Special="{StaticResource Special}"/>
</ResourceDictionary>
</ContentPage.Resources>
<ListView
SeparatorVisibility="Default"
CachingStrategy="RecycleElement"
Style="{StaticResource NoteNewsListView}"
GroupDisplayBinding="{Binding Key}"
IsGroupingEnabled="True"
IsRefreshing="{Binding IsBusy, Mode=OneWay}"
SelectedItem="{Binding CurrentGoods, Mode=TwoWay}"
ItemsSource="{Binding GoodsGroup}"
RefreshCommand="{Binding RefreshCommand}"
ItemTemplate="{StaticResource GoodsSelector}">
<ListView.Behaviors>
<xct:EventToCommandBehavior
Command="{Binding SelectedCommand}"
EventName="ItemSelected" />
</ListView.Behaviors>
<ListView.GroupHeaderTemplate>
<DataTemplate x:DataType="{x:Null}">
<ViewCell>
<StackLayout Padding="0,0,0,0" Margin="10,0,0,0">
<Label Style="{StaticResource LabelLarge}" Text="{Binding Key}" />
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.GroupHeaderTemplate>
<ListView.Header>
<StackLayout Orientation="Horizontal">
<Label
Margin="80"
FontFamily="AC"
HorizontalOptions="Center"
Style="{StaticResource LabelLarge}"
Text="Catalog Products">
</Label>
</StackLayout>
</ListView.Header>
<ListView.Footer>
<StackLayout HorizontalOptions="Center" Orientation="Horizontal">
<Button
Command="{Binding LoadMoreCommand}"
Style="{StaticResource ButtonOutline}"
Text="Load more" />
</StackLayout>
</ListView.Footer>
</ListView>
and my styles
<Style x:Key="ServiceCard" TargetType="Frame">
<Setter Property="HasShadow"
Value="{OnPlatform Android=true, iOS=false, Default=true}"/>
<Setter Property="CornerRadius" Value="20"/>
<Setter Property="BackgroundColor"
Value="{AppThemeBinding Dark={StaticResource CardBackgroundDark},
Light={StaticResource CardBackground}}"/>
</Style>
<Style x:Key="NoteNewsListView" TargetType="ListView">
<Setter Property="HasUnevenRows" Value="True"/>
<Setter Property="BackgroundColor" Value="Transparent"/>
<Setter Property="SeparatorVisibility"
Value="None"/>
<Setter Property="RefreshControlColor"
Value="{StaticResource SystemBlue}"/>
<Setter Property="IsPullToRefreshEnabled"
Value="True"/>
</Style>
how to do like below picture?
thanks #Jason for advice to add backgroundcolor to my labels
We can create two Labels to display Name and Price.
<Grid xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:models="clr-namespace:Notes.Models;assembly=Notes"
x:DataType="models:Goods"
x:Class="Notes.Cells.ProductCard">
<Frame Style="{StaticResource ProductCard}" BackgroundColor="Coral">
<StackLayout Orientation="Horizontal">
<Label
BackgroundColor="Aqua"
HorizontalTextAlignment="Start"
HorizontalOptions="FillAndExpand">
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding Name}" Style="{StaticResource LabelMedium}" BackgroundColor="Blue"></Span>
</FormattedString>
</Label.FormattedText>
</Label>
<Label HorizontalOptions="End">
<Label.FormattedText>
<FormattedString>
<Span Text="Price: " BackgroundColor="Green"/>
<Span Text="{Binding Price}" FontAttributes="Bold" BackgroundColor="Yellow"/>
</FormattedString>
</Label.FormattedText>
</Label>
</StackLayout>
</Frame>
<CollectionView x:Name="nList" SelectionMode="Single" VerticalScrollBarVisibility="Always" SelectionChanged="OnMakingSelection" >
<CollectionView.ItemTemplate>
<DataTemplate>
<StackLayout>
<SwipeView>
<SwipeView.RightItems>
<SwipeItem Text="Delete" BackgroundColor="Red" Invoked="Delete_Btn" >
</SwipeItem>
</SwipeView.RightItems>
<StackLayout BackgroundColor="AntiqueWhite">
<Label Text="{Binding UserNotes}" TextColor="Black" FontFamily="PK" FontAttributes="Bold" FontSize="33" HorizontalOptions="Center"/>
<Label x:Name="loclabel" Text= "{Binding Location}" FontAttributes="Bold" TextColor="Black" HorizontalOptions="Center" />
<Button x:Name="mapbtnnn" Text="Open in Maps" FontFamily="PF" Clicked="Button_Clicked_Map" BackgroundColor="PowderBlue" CornerRadius="40" HorizontalOptions="Center"></Button>
<Image x:Name="Image" Source="{Binding Pic}" HeightRequest="90" ></Image>
<Label Text="*END OF NOTE*" FontAttributes="Bold" TextColor="Black" HorizontalOptions="Center"/>
</StackLayout>
</SwipeView>
</StackLayout>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
Wanting to add colour to the selected item when sleceted.
Any tips,
I have tried a lot of steps online but none seem to work.
At the moment no colour is shown when selected
Wanting to add color to the selected item when selected.
You could use visual-state-manager to change the color of selected item,set swip background color as white, and add VisualStateManager.VisualStateGroups for swip like below:
<CollectionView x:Name="nList" SelectionMode="Single">
<CollectionView.ItemTemplate>
<DataTemplate>
<SwipeView BackgroundColor="White">
<SwipeView.RightItems>
<SwipeItem Text="Delete" BackgroundColor="Red" >
</SwipeItem>
</SwipeView.RightItems>
<StackLayout Padding="5" Orientation="Vertical">
<Label LineBreakMode="WordWrap" Text="{Binding Name}" />
</StackLayout>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup Name="CommonStates">
<VisualState Name="Normal" />
<VisualState Name="Selected">
<VisualState.Setters>
<Setter Property="BackgroundColor" Value="Yellow" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</SwipeView>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
Code behind:
public partial class Page1 : ContentPage
{
public Page1()
{
InitializeComponent();
nList.ItemsSource = new List<Contact>
{
new Contact("JP Morgan"),
new Contact("Andrew Carnegie"),
new Contact("Steve Jobs")
};
}
}
public class Contact
{
public string Name { get; set; }
public Contact(string name)
{
Name = name;
}
}
I have a SwipeCardView and I want to get the id of the user that I've just swiped.
<swipeCardView:SwipeCardView
x:Name="SwipeView1" ItemsSource="{Binding Profiles}" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
Padding="10" >
<swipeCardView:SwipeCardView.ItemTemplate>
<DataTemplate>
<StackLayout HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<Frame CornerRadius="10"
Padding="8"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<AbsoluteLayout>
<AbsoluteLayout.GestureRecognizers>
<SwipeGestureRecognizer Direction="Left" Command="{Binding LeftCommand}"
CommandParameter="{Binding nome}" />
</AbsoluteLayout.GestureRecognizers>
<Image Source="{Binding foto_perfil}"
Aspect="AspectFill"
AbsoluteLayout.LayoutBounds=".5,0.5,1,1"
AbsoluteLayout.LayoutFlags="All" />
<Label FontSize="Large"
WidthRequest="30"
FontAttributes="Bold"
TextColor="White"
BackgroundColor="Black"
AbsoluteLayout.LayoutBounds="0.1,0.95,250,30"
AbsoluteLayout.LayoutFlags="PositionProportional">
<Label.FormattedText>
<FormattedString>
<Span Text="{Binding nome}" />
<Span Text=", " />
<Span Text="{Binding data_nasc}" />
</FormattedString>
</Label.FormattedText>
</Label>
</AbsoluteLayout>
</Frame>
</StackLayout>
</DataTemplate>
</swipeCardView:SwipeCardView.ItemTemplate>
</swipeCardView:SwipeCardView>
In the C# I created a command but it never enter i the void:
public Command LeftCommand => new Command<string>(LeftSwipe);
void LeftSwipe(string parameter)
{
var variable = parameter; //= breed_Name
DisplayAlert("", variable.ToString(), "ok");
}
I don´t know what I've done wrong because it still swipes
If your LeftCommand is in the ViewModel of your page, you can specify a source just as Jason said.
You can refer to the folloing code:
<swipeCardView:SwipeCardView x:Name="mCardView"
ItemsSource="{Binding CardItems}"
VerticalOptions="FillAndExpand">
<swipeCardView:SwipeCardView.ItemTemplate>
<DataTemplate>
<StackLayout >
<Label Text="{Binding Name}" FontSize="Large" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" BackgroundColor="Beige" />
<StackLayout.GestureRecognizers>
<SwipeGestureRecognizer Direction="Left"
Command="{Binding Path=BindingContext.LeftCommand, Source={x:Reference mCardView}}"
CommandParameter="{Binding .}" >
</SwipeGestureRecognizer>
</StackLayout.GestureRecognizers>
</StackLayout>
</DataTemplate>
</swipeCardView:SwipeCardView.ItemTemplate>
</swipeCardView:SwipeCardView>
Note:
1.mCardView is the x:Name="mCardView" of your SwipeCardView;
2.In your viewModel, you can get the Binded Item as follows:
public Command LeftCommand => new Command(LeftSwipe);
void LeftSwipe(Object parameter)
{
//You can change `Profile ` to your Item Model
Profile variable = parameter as Profile;
System.Diagnostics.Debug.WriteLine("-----------> " + variable.Name +"<---> Id = "+ variable.ProfileId);
}
Screen
On the picture above you can see where the ImageButton sometimes activates. When I spam clicking in the blue area the counter sometimes increases. I think there might be another Layer on top of the ImageButton but I dont know how to fix it. Below there is the XAML code. Hopefully somebody can help. Thanks!
<StackLayout>
<Label Text="Discover" TextColor="Black" FontSize="24" FontAttributes="Bold" Margin="15" />
<CarouselView ItemsSource="{Binding plants}" HeightRequest="300" PeekAreaInsets="100">
<CarouselView.ItemTemplate>
<DataTemplate>
<StackLayout>
<Frame HeightRequest="280" WidthRequest="180" BackgroundColor="Wheat" HasShadow="True" Margin="10" Padding="0" HorizontalOptions="CenterAndExpand" CornerRadius="10" >
<Grid>
<StackLayout>
<ImageButton Source="{Binding imgsource}" VerticalOptions="FillAndExpand"
Aspect="AspectFill" Opacity="0.8" Clicked="ImageButton_Clicked"/>
</StackLayout>
<StackLayout Margin="0,10" >
<Image Source="https://icons-for-free.com/iconfiles/png/512/bookmark-131964752402712733.png" HeightRequest="35"
Aspect="AspectFit" HorizontalOptions="EndAndExpand" Margin="5,-15"/>
<Label Text="{Binding name_norm}" TextColor="Black" FontSize="16" FontAttributes="Bold"
Margin="15,-10,0,0" VerticalOptions="EndAndExpand" />
<StackLayout Orientation="Horizontal" Margin="15,-8,0,0" >
<Image Source="https://www.freeiconspng.com/thumbs/info-icon/info-icon-24.png" HeightRequest="15"
Aspect="AspectFit"/>
<Label Text="{Binding name_lat}" TextColor="Black" FontSize="16" FontAttributes="Italic" VerticalOptions="EndAndExpand" Margin="-5,0" />
</StackLayout>
</StackLayout>
</Grid>
</Frame>
</StackLayout>
</DataTemplate>
</CarouselView.ItemTemplate>
</CarouselView>
<Label x:Name="label" Text="0 ImageButton clicks"
FontSize="Large"
HorizontalOptions="Center"
VerticalOptions="CenterAndExpand" />
</StackLayout>
Here the C# Code:
namespace PlantBase
{
public partial class MainPage : ContentPage
{
int clickTotal;
public MainPage()
{
InitializeComponent();
}
private void ImageButton_Clicked(object sender, EventArgs e)
{
clickTotal += 1;
label.Text = $"{clickTotal} ImageButton click{(clickTotal == 1 ? "" : "s")}";
}
}
}
Check VisualElement.InputTransparent Property.
false if the element and its children should receive input; true if neither the element nor its children should receive input and should, instead, pass inputs to the elements that are visually behind the current visual element. Default is false.
What you need is to set InputTransparent to true on the text stackLayout .
<StackLayout InputTransparent="True" Margin="0,10" VerticalOptions="EndAndExpand" BackgroundColor="SaddleBrown">
<Label Text="{Binding name_norm}" TextColor="White" FontSize="16" FontAttributes="Bold" Margin="15,-10,0,0" VerticalOptions="EndAndExpand" />
<StackLayout Orientation="Horizontal" Margin="15,-8,0,0" BackgroundColor="Aqua">
<Image Source="https://www.freeiconspng.com/thumbs/info-icon/info-icon-24.png" HeightRequest="15" Aspect="AspectFit" />
<Label Text="{Binding name_lat}" TextColor="White" FontSize="16" FontAttributes="Italic" VerticalOptions="EndAndExpand" Margin="-5,0" />
</StackLayout>
</StackLayout>
Okay I found the Problem. It was that before I put the red Flag on the Top and the text at the bottom in one Stacklayout which expanded from top to bottom. Now that i put them in seperate StackLayouts it works and the ImageButton is free.
Pictures before/after.
old StackLayout
new Stacklayout
The new XAML is:
<CarouselView ItemsSource="{Binding plants}" HeightRequest="300" PeekAreaInsets="100">
<CarouselView.ItemTemplate>
<DataTemplate>
<StackLayout>
<Frame HeightRequest="280" WidthRequest="180" BackgroundColor="Wheat" HasShadow="True" Margin="10" Padding="0" HorizontalOptions="CenterAndExpand" CornerRadius="10" >
<Grid>
<StackLayout>
<ImageButton Source="{Binding imgsource}" VerticalOptions="FillAndExpand"
Aspect="AspectFill" Opacity="0.9" Clicked="ImageButton_Clicked" />
</StackLayout>
<StackLayout VerticalOptions="StartAndExpand" HorizontalOptions="EndAndExpand" BackgroundColor="Aqua">
<ImageButton Source="https://icons-for-free.com/iconfiles/png/512/bookmark-131964752402712733.png" HeightRequest="35"
Aspect="AspectFit" HorizontalOptions="EndAndExpand" Margin="5,0" BackgroundColor="Transparent" Clicked="ImageButton_Clicked_1" />
</StackLayout>
<StackLayout Margin="0,10" VerticalOptions="EndAndExpand" BackgroundColor="SaddleBrown">
<Label Text="{Binding name_norm}" TextColor="White" FontSize="16" FontAttributes="Bold"
Margin="15,-10,0,0" VerticalOptions="EndAndExpand" />
<StackLayout Orientation="Horizontal" Margin="15,-8,0,0" BackgroundColor="Aqua" >
<Image Source="https://www.freeiconspng.com/thumbs/info-icon/info-icon-24.png" HeightRequest="15"
Aspect="AspectFit" />
<Label Text="{Binding name_lat}" TextColor="White" FontSize="16" FontAttributes="Italic" VerticalOptions="EndAndExpand" Margin="-5,0" />
</StackLayout>
</StackLayout>
</Grid>
</Frame>
</StackLayout>
</DataTemplate>
</CarouselView.ItemTemplate>
New Question now. Since at the bottom there is the Text StackLayout, where the Text is I cant press the ImageButton. How can I put the ImageButton as top "layer" so I can also press it while pressing on the text.
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