My application calls two templates that create something similar to two ViewCells:
<StackLayout Orientation="Horizontal" Padding="10">
<template:DataGridTemplate Text="Updated" Label="{Binding Updated}" />
<template:DataGridTemplate Text="Version" Label="{Binding Version}" />
</StackLayout>
Here's the template XAML
<?xml version="1.0" encoding="utf-8"?>
<Grid Padding="20,0" xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Japanese;assembly=Japanese"
x:Class="Japanese.Templates.DataGridTemplate"
x:Name="this">
<local:StyledLabel Text="{Binding Text, Source={x:Reference this}}" HorizontalOptions="Start" VerticalTextAlignment="Center" />
<local:StyledLabel Text="{Binding Label, Source={x:Reference this}}" HorizontalOptions="End" VerticalTextAlignment="Center" />
</Grid>
I would like the height of the template to be 50 and also to have a line created between the two templates to simulate something like I would find in a ViewCell that's inside a TableSection.
Does anyone have any suggestions how I can do this? I tried setting the height of the Grid to 50 but it tells me that it's a read only property.
StackLayout
<StackLayout Orientation="Vertical" Padding="10" Spacing="0">
<template:DataGridTemplate Text="Updated" Label="07/21/2018" />
<template:DataGridTemplate Text="Version" Label="1.0.0" />
</StackLayout>
DataGridTemplate (the line separator is in here, but could be added directly to the StackLayout instead)
<?xml version="1.0" encoding="utf-8"?>
<Grid Padding="20,0" HeightRequest="50" xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Sof2"
x:Class="Sof2.Templates.DataGridTemplate"
x:Name="this">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<local:StyledLabel Grid.Column="0" Text="{Binding Text, Source={x:Reference this}}" VerticalTextAlignment="Center" />
<local:StyledLabel Grid.Column="1" Text="{Binding Label, Source={x:Reference this}}" TextColor="Silver" VerticalTextAlignment="Center" />
<!-- Separator -->
<BoxView Grid.ColumnSpan="2" BackgroundColor="Silver" HeightRequest="1" VerticalOptions="End" />
</Grid>
Result
If interactivity is needed, then you could add TapGestureRecognizers as appropriate.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.