How do I get my CollectionView to use the last column in the GridItemsLayout span? No matter if I set the span as 2, 3, 4, the last column is always empty.
For instance, if the span is set to 3, this is what it looks like.
Here's my xaml:
<Frame Grid.Column="1" Grid.Row="0" Margin="10, 25, 25, 25" Padding="25">
<VerticalStackLayout>
<CollectionView x:Name="listToolOptions"
ItemsSource="{Binding Tools_Visible}"
Margin="0"
SelectionMode="None">
<CollectionView.ItemsLayout>
<GridItemsLayout Orientation="Vertical" Span="3" VerticalItemSpacing="5" HorizontalItemSpacing="5" />
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<Frame BorderColor="#f1f1f1">
<Frame.Triggers>
<DataTrigger TargetType="Frame" Binding="{Binding Selected}" Value="True">
<Setter Property="BorderColor" Value="{StaticResource Primary}"/>
</DataTrigger>
</Frame.Triggers>
<Frame.GestureRecognizers>
<TapGestureRecognizer Tapped="ToolTapped"/>
</Frame.GestureRecognizers>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="15"/>
<ColumnDefinition Width="75"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image Grid.Column="0" Grid.Row="0" Grid.RowSpan="4" WidthRequest="15" HorizontalOptions="Center" VerticalOptions="Center" IsVisible="{Binding Unselected}">
<Image.Source>
<FontImageSource FontFamily="FA" Glyph="" Color="{StaticResource Secondary}" Size="15"/>
</Image.Source>
</Image>
<Image Grid.Column="0" Grid.Row="0" Grid.RowSpan="4" WidthRequest="15" HorizontalOptions="Center" VerticalOptions="Center" IsVisible="{Binding Selected}">
<Image.Source>
<FontImageSource FontFamily="FA" Glyph="" Color="{StaticResource Primary}" Size="15"/>
</Image.Source>
</Image>
<Label Grid.Column="1" Grid.Row="0" Text="Part:" FontAttributes="Bold" Padding="0, 0, 5, 0" HorizontalTextAlignment="End"/>
<Label Grid.Column="2" Grid.Row="0" Grid.ColumnSpan="2" Text="{Binding Name}" HorizontalOptions="StartAndExpand" />
<Label Grid.Column="1" Grid.Row="1" Text="S/N:" FontAttributes="Bold" Padding="0, 0, 5, 0" HorizontalTextAlignment="End"/>
<Label Grid.Column="2" Grid.Row="1" Text="{Binding Serial}" />
<Label Grid.Column="1" Grid.Row="2" Text="Mfg.:" FontAttributes="Bold" Padding="0, 0, 5, 0" HorizontalTextAlignment="End"/>
<Label Grid.Column="2" Grid.Row="2" Text="{Binding Manufacturer}" />
<Label Grid.Column="1" Grid.Row="3" Text="Cal Due:" FontAttributes="Bold" Padding="0, 0, 5, 0" HorizontalTextAlignment="End"/>
<Label Grid.Column="2" Grid.Row="3" Text="{Binding Path=CalDueDate, StringFormat='{0:MM/dd/yyyy}'}" />
</Grid>
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</VerticalStackLayout>
</Frame>
Is this a bug with UWP or am I doing something wrong that I'm just missing?
Related
My test phone is LG-V50 and LG-G6 and Note5
my test collectionview code
<CollectionView Grid.Row="1" ItemsSource="{Binding Model.ViewList}" SelectedItem="{Binding Model.SelectedView}" >
<CollectionView.ItemsLayout>
<LinearItemsLayout Orientation="Vertical" ItemSpacing="10"/>
</CollectionView.ItemsLayout>
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Margin="2" VerticalOptions="FillAndExpand">
<Frame Grid.Row="0" WidthRequest="500" CornerRadius="8" BackgroundColor="#FFEAEAEA" HorizontalOptions='FillAndExpand' Margin="0" VerticalOptions="FillAndExpand">
<Grid Margin="-15,-10,-15,0">
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="5"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="5"/>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<StackLayout Grid.Row="0" Orientation="Horizontal" HorizontalOptions="FillAndExpand">
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Orientation="Horizontal" BackgroundColor="AliceBlue" >
<Label x:Name="test" Text="{Binding DeviceName}" Style="{StaticResource DiviceTitel01}" FontSize="30" />
</StackLayout>
<Button Image="close.png" WidthRequest="50" HeightRequest="50" Command="{Binding Source={x:Reference BoardName}, Path=BindingContext.ViewListDeleteCommand}" CommandParameter="{Binding Source={x:Reference test},Path=Text}" Style="{StaticResource ExitBtnStyle}" HorizontalOptions="Center"/>
</StackLayout>
<customControls:Board Grid.Row="2" BindingContext="{Binding VM}" VerticalOptions="FillAndExpand"/>
<StackLayout Grid.Row="4" Orientation="Horizontal" HorizontalOptions="CenterAndExpand" Margin="-10,0,-10,0">
<Button Text="button1" FontSize="25" FontAttributes="Bold" WidthRequest="140" HeightRequest="50" Command="{Binding Source={x:Reference BoardName}, Path=BindingContext.InfoPageClickCommand}" CommandParameter="{Binding Source={x:Reference test},Path=Text}" Style="{StaticResource InfoBtnStyle}" />
<Button Text="button1" FontSize="25" FontAttributes="Bold" WidthRequest="120" HeightRequest="50" Command="{Binding Source={x:Reference BoardName}, Path=BindingContext.DetailDataClickCommand}" CommandParameter="{Binding Source={x:Reference test},Path=Text}" Style="{StaticResource DetailviewBtnStyle}"/>
<Button Text="button2" FontSize="25" FontAttributes="Bold" WidthRequest="120" HeightRequest="50" Command="{Binding Source={x:Reference BoardName}, Path=BindingContext.RefPageCommand}" CommandParameter="{Binding Source={x:Reference test},Path=Text}" Style="{StaticResource MoveBtnStyle}" TextColor="black"/>
</StackLayout>
</Grid>
</Frame>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
and listview test code
<ListView x:Name="ListView" Grid.Row="1" BackgroundColor="White" Margin="0"
ItemsSource="{Binding Model.ViewList}"
SelectedItem="{Binding Model.SelectedView}"
HasUnevenRows="True"
IsPullToRefreshEnabled="False"
>
<ListView.ItemTemplate>
<DataTemplate>
<customControls:ExtendedViewCell SelectedBackgroundColor="#FF8FB5C3" >
<ViewCell.View>
<Grid Margin="2" VerticalOptions="FillAndExpand">
<Frame Grid.Row="0" WidthRequest="500" CornerRadius="8" BackgroundColor="#FFEAEAEA" HorizontalOptions='FillAndExpand' Margin="0" VerticalOptions="FillAndExpand">
<Grid Margin="-15,-10,-15,0">
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="5"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="5"/>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<StackLayout Grid.Row="0" Orientation="Horizontal" HorizontalOptions="FillAndExpand">
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" Orientation="Horizontal" BackgroundColor="AliceBlue" >
<Label x:Name="test" Text="{Binding DeviceName}" Style="{StaticResource DiviceTitel01}" FontSize="30" />
</StackLayout>
<Button Image="close.png" WidthRequest="50" HeightRequest="50" Command="{Binding Source={x:Reference BoardName}, Path=BindingContext.ViewListDeleteCommand}" CommandParameter="{Binding Source={x:Reference test},Path=Text}" Style="{StaticResource ExitBtnStyle}" HorizontalOptions="Center"/>
</StackLayout>
<customControls:Board Grid.Row="2" BindingContext="{Binding VM}" VerticalOptions="FillAndExpand"/>
<StackLayout Grid.Row="4" Orientation="Horizontal" HorizontalOptions="CenterAndExpand" Margin="-10,0,-10,0">
<Button Text="buuton1" FontSize="25" FontAttributes="Bold" WidthRequest="140" HeightRequest="50" Command="{Binding Source={x:Reference BoardName}, Path=BindingContext.InfoPageClickCommand}" CommandParameter="{Binding Source={x:Reference test},Path=Text}" Style="{StaticResource InfoBtnStyle}" />
<Button Text="button2" FontSize="25" FontAttributes="Bold" WidthRequest="120" HeightRequest="50" Command="{Binding Source={x:Reference BoardName}, Path=BindingContext.DetailDataClickCommand}" CommandParameter="{Binding Source={x:Reference test},Path=Text}" Style="{StaticResource DetailviewBtnStyle}"/>
<Button Text="button3" FontSize="25" FontAttributes="Bold" WidthRequest="120" HeightRequest="50" Command="{Binding Source={x:Reference BoardName}, Path=BindingContext.RefPageCommand}" CommandParameter="{Binding Source={x:Reference test},Path=Text}" Style="{StaticResource MoveBtnStyle}" TextColor="black"/>
</StackLayout>
</Grid>
</Frame>
</Grid>
</ViewCell.View>
</customControls:ExtendedViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
and
my customcontrol code
<Grid IsVisible="{Binding Model.IsWlevelControlVisible}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Grid.Column="0" BackgroundColor="{Binding Model.Color0}" VerticalOptions="FillAndExpand" Margin="-2">
<Grid.RowDefinitions>
<RowDefinition Height="55"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="70"/>
</Grid.ColumnDefinitions>
<Label x:Name="W0" Text="{Binding Model.Title_0}" LineBreakMode="TailTruncation" Grid.Row="0" Grid.Column="0" TextColor="White" HorizontalTextAlignment="Start" VerticalTextAlignment="Center" Margin="15,0,0,0" FontSize="24" />
<Label Text="{Binding Model.AIValue_0}" Grid.Row="0" TextColor="White" HorizontalTextAlignment="End" VerticalTextAlignment="Center" Font="23"/>
<Label Text="{Binding Model.Value_0, Converter={StaticResource StingFormatConverter}, ConverterParameter={x:Reference F0}}" Grid.Row="1" Grid.Column="0" FontSize="23" TextColor="White" HorizontalTextAlignment="End" VerticalTextAlignment="Center" Margin="0,0,-40,0"/>
<Label Text="{Binding Model.Value_0, Converter={StaticResource UnitConverter}, ConverterParameter={x:Reference F0}}" Grid.Row="1" Grid.Column="1" FontSize="22" TextColor="White" HorizontalTextAlignment="End" VerticalTextAlignment="Center" Margin="0,0,5,0"/>
</Grid>
<Grid Grid.Row="0" Grid.Column="1" VerticalOptions="FillAndExpand" Margin="-2">
<Label Grid.Row="0" Text="{Binding Model.Time}" TextColor="White" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="18"/>
</Grid>
</Grid>
and Customcontrol Data communication is updated every 2 seconds
It is slow to draw an item except for data communication and without binding.
Excluding controls in collection view and list view makes drawing items fast, but adding controls makes drawing items very slow.
Can you find a solution to this problem?
I have a problem. I want to make a custom header, so I created this stacklayout:
<StackLayout VerticalOptions="Start" HeightRequest="50" HorizontalOptions="CenterAndExpand">
<Image HorizontalOptions="Start" Source="Logo.png"/>
<Image HorizontalOptions="Start" Source="Title_Dark.png"/>
</StackLayout>
Now I want to put it above the following code:
<ContentPage.Content>
<ListView x:Name="ListViewMain" VerticalOptions="FillAndExpand" BackgroundColor="#212121" SelectionMode="None">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Label HeightRequest="1" BackgroundColor="#E3E3E3" />
<Grid x:Name="GridMain">
<Grid.RowDefinitions>
<RowDefinition Height="40" x:Name="Row0_Height"/>
<RowDefinition Height="180" x:Name="Row1_Height"/>
<RowDefinition Height="180" x:Name="Row2_Height"/>
<RowDefinition Height="40" x:Name="Row3_Height"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="40" x:Name="Column0_Width" />
<ColumnDefinition Width="*" x:Name="Column1_Width" />
<ColumnDefinition Width="40" x:Name="Column2_Width" />
</Grid.ColumnDefinitions>
<Label Text="{Binding Creator}" TextColor="White" FontSize="Body" FontAttributes="Bold" Grid.Column="1" Grid.Row="0" VerticalOptions="Center" HorizontalOptions="Start"/>
<Image Source="VoteUp.png" VerticalOptions="End" HorizontalOptions="Center" Grid.Row="1" Grid.Column="0">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="imgVoteUp_Clicked" />
</Image.GestureRecognizers>
</Image>
<Image Source="VoteDown.png" VerticalOptions="Start" HorizontalOptions="Center" Grid.Row="2" Grid.Column="0">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="imgVoteDown_Clicked" />
</Image.GestureRecognizers>
</Image>
<Image Source="{Binding ImageLocation}" Margin="0, 0, 20, 0" Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1" Grid.RowSpan="2" BackgroundColor="AliceBlue" VerticalOptions="Fill" HorizontalOptions="Fill"/>
<Image Source="Favorite.png" Grid.Row="3" Grid.Column="1" HorizontalOptions="Start">
<Image.GestureRecognizers>
<TapGestureRecognizer Tapped="imgFavorite_Clicked" />
</Image.GestureRecognizers>
</Image>
<Image Source="Send_Dark.png" Grid.Row="3" Grid.Column="1" HorizontalOptions="End"/>
<Image Source="Save_Dark.png" Grid.Row="3" Grid.Column="2" HorizontalOptions="End"/>
</Grid>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage.Content>
But when I put it right under the <ContentPage.Content> tag, it gives the following error:
The property 'Content' is set more than once
When I put it above the <ContentPage.Content> tag, my whole screen is the header.
How can I fix this?
Content can only have ONE child element. If you want to have multiple child elements, you need to place them inside of a layout container (Grid, StackLayout, etc)
I've been trying to put border on these text and the only way i can is taking off grid on every row so now it has borders but then the grid frame is off. I can't differentiate which part is from row1 or the beginning of list.
<StackLayout>
<Label Text="rain Log" VerticalOptions="Center" HorizontalOptions="Center" Margin="0,50,0,0" />
<ListView x:Name="postListView" >
<ListView.ItemTemplate>
<!-- from the post.cs -->
<DataTemplate>
<ViewCell >
<Grid BackgroundColor="Black" HorizontalOptions="CenterAndExpand" VerticalOptions="FillAndExpand">
<Grid.RowDefinitions > <!-- 8 rows -->
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<!-- Row 1 -->
<Label Grid.Row="1" FontSize="Medium" Grid.Column="0" Text="right tst:" HorizontalTextAlignment="Start" BackgroundColor="cornflowerblue" />
<Label Grid.Column="1" Grid.Row="1" Text="{Binding drain1vol}" BackgroundColor="cornflowerblue"/>
<!-- endrow1 -->
<!-- rain1 Row 1 -->
<Label Grid.Row="2" Grid.Column="0" Text="nothing" BackgroundColor="Yellow"/>
<Label Grid.Row="2" Grid.Column="1" Text="{Binding drain2vol}"
HorizontalTextAlignment="Center" BackgroundColor="Yellow" />
<!-- endrow1 -->
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</ContentPage>
what i want
If you want to separate out your item as like group than you can use SeparatorColor and its visibility.
Instead of 2 boxview you can also use one grid as wrapper and using ColumnSpacing and RowSpacing.
<ListView x:Name="postListView" SeparatorVisibility="Default" HasUnevenRows="True" ItemsSource="{Binding Items}" SeparatorColor="White">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid BackgroundColor="Black" HorizontalOptions="CenterAndExpand"
VerticalOptions="FillAndExpand" Padding="1,2,1,0">
<Grid HorizontalOptions="CenterAndExpand"
VerticalOptions="FillAndExpand" ColumnSpacing="1" RowSpacing="1">
<Grid.RowDefinitions >
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" FontSize="Medium" Grid.Column="0" Text="right tst:" HorizontalTextAlignment="Start" BackgroundColor="cornflowerblue" />
<Label Grid.Column="1" Grid.Row="0" Text="{Binding drain1vol}" HorizontalTextAlignment="Center" BackgroundColor="cornflowerblue"/>
<Label Grid.Row="1" Grid.Column="0" Text="nothing" BackgroundColor="Yellow"/>
<Label Grid.Row="1" Grid.Column="1" Text="{Binding drain2vol}" HorizontalTextAlignment="Center" BackgroundColor="Yellow" />
</Grid>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Yes, you can use BoxView to achieve this function, try the following code :
<StackLayout>
<Label Text="rain Log" VerticalOptions="Center" HorizontalOptions="Center" Margin="0,50,0,0" />
<ListView x:Name="postListView" HasUnevenRows="True">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell >
<Grid HorizontalOptions="CenterAndExpand" VerticalOptions="FillAndExpand" ColumnSpacing="2" RowSpacing="0" BackgroundColor="Black">
<Grid.RowDefinitions >
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" FontSize="Medium" Grid.Column="0" Text="right tst:" HorizontalTextAlignment="Start" BackgroundColor="cornflowerblue" />
<Label Grid.Column="1" Grid.Row="0" Text="{Binding drain1vol}" HorizontalTextAlignment="Center" BackgroundColor="cornflowerblue"/>
<!-- thin separator -->
<BoxView Color="Black" Grid.Row="0" Grid.ColumnSpan="2" HeightRequest="2" VerticalOptions="End" HorizontalOptions="FillAndExpand" />
<Label Grid.Row="1" Grid.Column="0" Text="nothing" BackgroundColor="Yellow"/>
<Label Grid.Row="1" Grid.Column="1" Text="{Binding drain2vol}" HorizontalTextAlignment="Center" BackgroundColor="Yellow" />
<!-- thick separator -->
<BoxView Color="Black" Grid.Row="3" Grid.ColumnSpan="2" HeightRequest="5" VerticalOptions="End" HorizontalOptions="FillAndExpand" />
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
The effect is as follows:
use a BoxView overlaid on your Grid to simulate a separator
<Grid HorizontalOptions="CenterAndExpand" VerticalOptions="FillAndExpand">
<!-- Row 1 -->
<Label Grid.Row="1" FontSize="Medium" Grid.Column="0" Text="right tst:" HorizontalTextAlignment="Start" BackgroundColor="cornflowerblue" />
<Label Grid.Column="1" Grid.Row="1" Text="{Binding drain1vol}" BackgroundColor="cornflowerblue"/>
<! thin separator -->
<BoxView Color="Black" Grid.Row="1" Grid.ColumnSpan="2" HeightRequest="2" VerticalOptions="End" HorizontalOptions="FillAndExpand" />
<!-- rain1 Row 1 -->
<Label Grid.Row="2" Grid.Column="0" Text="nothing" BackgroundColor="Yellow"/>
<Label Grid.Row="2" Grid.Column="1" Text="{Binding drain2vol}"
HorizontalTextAlignment="Center" BackgroundColor="Yellow" />
<! thick separator -->
<BoxView Color="Black" Grid.Row="2" Grid.ColumnSpan="2" HeightRequest="5" VerticalOptions="End" HorizontalOptions="FillAndExpand" />
</Grid>
Why is only half of the text being displayed in the labels at the bottom?
This is my xaml. The listview area is 300, and each listview row is 100 (set in <On Platform="Android">100</On>).
Each ViewCell has 4 rows, with each row being 25, for a total of 100 (the listview row height).
So I don't understand why only half of the text at the bottom is displayed, or why the space taken up by row 0 & 1 of column 2 isn't exactly half of the total height.
<Grid RowSpacing="0">
<Grid.RowDefinitions>
<RowDefinition Height="100" />
<RowDefinition Height="300" />
</Grid.RowDefinitions>
<StackLayout Grid.Row="0" x:Name="MapGrid">
<maps:Map WidthRequest="960" HeightRequest="100"
x:Name="MyMap" IsShowingUser="true"/>
</StackLayout>
<StackLayout Grid.Row="1" x:Name="listSection" HeightRequest="300">
<ListView x:Name="ListView_Pets">
<ListView.RowHeight>
<OnPlatform x:TypeArguments="x:Int32">
<On Platform="Android">100</On>
</OnPlatform>
</ListView.RowHeight>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25"></RowDefinition>
<RowDefinition Height="25"></RowDefinition>
<RowDefinition Height="25"></RowDefinition>
<RowDefinition Height="25"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50*" />
<ColumnDefinition Width="25*"/>
<ColumnDefinition Width="25*"/>
</Grid.ColumnDefinitions>
<Label Text="Name" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="15" TextColor="Black" Grid.Row="0" Grid.Column="0"/>
<Label Text="Address" HorizontalTextAlignment="Center" VerticalTextAlignment="Start" FontSize="10" TextColor="Black" Grid.Row="1" Grid.Column="0"/>
<Label Text="Price1" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="15" TextColor="White" BackgroundColor="#2FA4D9" Grid.Row="0" Grid.Column="2"/>
<Label Text="Price2" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="15" TextColor="White" BackgroundColor="#2FA4D9" Grid.Row="1" Grid.Column="2"/>
<Label Text="Tag1" Grid.Row="0" VerticalTextAlignment="Center" HorizontalTextAlignment="End" Grid.Column="1" FontSize="Micro"/>
<Label Text="Tag2" Grid.Row="1" VerticalTextAlignment="Center" HorizontalTextAlignment="End" Grid.Column="1" FontSize="Micro"/>
<StackLayout Grid.Row="3" Grid.Column="0">
<StackLayout Orientation="Horizontal" >
<Label Text="Text1" FontSize="10" VerticalTextAlignment="Start" TextColor="Black" />
<Label Text="Text2" VerticalTextAlignment="Start" FontSize="10" TextColor="Black" />
<Label Text="Text3" VerticalTextAlignment="Start" FontSize="10" TextColor="Black" />
</StackLayout>
</StackLayout>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</Grid>
Here's the screenshot:
This is because of the Grid inside your ViewCell has a RowSpacing and ColumnSpacing defaults. To override this, just set <Grid RowSpacing=0 ColumnSpacing=0>
I have a card view and in that, I have an image. I have to set the corner radius for that image so I'm using frames for doing that.
This is the UI I need and I have marked the Image
This is the result I'm getting
.
This is my code
<xfx:XfxCardView
BackgroundColor="White"
CornerRadius="30"
Elevation="30"
HeightRequest="100" >
<Grid RowSpacing="0">
<Grid ColumnSpacing="0">
<Grid.RowDefinitions >
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions >
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Frame CornerRadius="10" Margin="0" Padding="0" IsClippedToBounds="True">
<Image Margin="-70,0,0,0" Source="restaurantimage1.jpg" Grid.Row="0" Grid.Column="0" Grid.RowSpan="3"/>
</Frame>
<Label Grid.Row="0" Grid.Column="1" Margin="0,0,100,0" BackgroundColor="Aqua" HorizontalOptions="Start" Text="Premera restaurant" TextColor="Black" FontFamily="Bold,20"/>
<Label Grid.Row="1" Grid.Column="1" Margin="0,0,100,0" BackgroundColor="Green" HorizontalTextAlignment="Start" Text="Avenue Road,256" TextColor="Blue"/>
<Label Grid.Row="2" Grid.Column="1" Margin="0,0,100,0" BackgroundColor="LightBlue" VerticalTextAlignment="Start" Text="Indian,Italy,Chinese" TextColor="LightGray"/>
</Grid>
</Grid>
</xfx:XfxCardView>
I have made changes in corner radius and margins but I'm not getting the desired result. Do I have to use something else to do that or should I make any changes in the Frame.
I have done some changes in code so and I'm slightly near to the desired output.
This is the current output
There is still a gap in the frame as you can see I have made changes in the code but still it is not getting fixed. This is my code
<xfx:XfxCardView
BackgroundColor="White"
CornerRadius="30"
Elevation="30"
HeightRequest="100" >
<Grid RowSpacing="0">
<Grid ColumnSpacing="0">
<Grid.RowDefinitions >
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions >
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Frame Margin="0" Padding="-40" CornerRadius="25" Grid.RowSpan="3" BackgroundColor="LightBlue" IsClippedToBounds="True">
<Image Margin="-70,0,0,0" Grid.Row="0" Grid.Column="0" Grid.RowSpan="3" BackgroundColor="AliceBlue" Source="restaurantimage1.jpg" />
</Frame>
<Label Grid.Row="0" Grid.Column="1" Margin="0,0,100,0" HorizontalOptions="Start" Text="Premera restaurant" TextColor="Black" FontFamily="Bold,20"/>
<Label Grid.Row="1" Grid.Column="1" Margin="0,0,100,0" HorizontalTextAlignment="Start" Text="Avenue Road,256" TextColor="Blue"/>
<Label Grid.Row="2" Grid.Column="1" Margin="0,0,100,0" VerticalTextAlignment="Start" Text="Indian,Italy,Chinese" TextColor="LightGray"/>
</Grid>
</Grid>
</xfx:XfxCardView>
Try setting the is clipped to bounds property as true in your Grid's xaml
<Grid RowSpacing="0" IsClippedToBounds="True">
I fixed it by changing the margin of my frame. This is my code now
<xfx:XfxCardView
BackgroundColor="White"
CornerRadius="30"
Elevation="20"
HeightRequest="150" IsClippedToBounds="True">
<Grid RowSpacing="0" >
<Grid ColumnSpacing="0">
<Grid.RowDefinitions >
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions >
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Frame Margin="10,10,10,20" Padding="-40" CornerRadius="10" Grid.RowSpan="3" BackgroundColor="LightBlue" IsClippedToBounds="True">
<Image Margin="-70,0,0,0" Grid.Row="0" Grid.Column="0" Grid.RowSpan="3" BackgroundColor="AliceBlue" Source="restaurantimage1.jpg" />
</Frame>
<Label Grid.Row="0" Grid.Column="1" Margin="0,30,30,0" HorizontalOptions="Start" Text="Premera restaurant" TextColor="Black" FontFamily="Bold,20"/>
<Image Grid.Row="0" Grid.Column="1" Margin="0,30,10,0" HorizontalOptions="End" Source="whitehearticon3.jpg"/>
<Label Grid.Row="1" Grid.Column="1" Margin="0,-20,40,0" HorizontalTextAlignment="Start" Text="Avenue Road,256" TextColor="Blue"/>
<Label Grid.Row="2" Grid.Column="1" Margin="0,0,40,0" VerticalTextAlignment="Start" Text="Indian,Italy,Chinese Kitchen" TextColor="LightGray"/>
</Grid>
</Grid>
</xfx:XfxCardView>