Hello,
I want to set margin on both sides of the area where item template is rendered.
Red rectangle is header template, blue area is item template.
How can I achieve this?
Thank you,
Paweł
|
<syncfusion:SfListView x:Name="listView"
Margin="10,10,10,10"
ItemsSource="{Binding contactsinfo}"> |
This is not what I'm trying to achieve. I attached a picture comparing different versions:
Hello,
I attached code files. Let me know if you need more information.
Thank you,
Paweł
|
public class MarginConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var item = value as Contacts;
var listview = parameter as SfListView;
if (item == null)
return null;
var itemIndex = listview.DataSource.DisplayItems.IndexOf(item) + 1;
var spanCount = (listview.LayoutManager as GridLayout).SpanCount;
if(itemIndex % spanCount == 1)
{
return new Thickness(15, 0, 0, 0);
}
else if(itemIndex % spanCount == 0)
{
return new Thickness(0, 0, 15, 0);
}
return new Thickness(0);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
|
|
<ContentPage.Resources>
<ResourceDictionary>
<local:MarginConverter x:Key="MarginConverter"/>
</ResourceDictionary>
</ContentPage.Resources>
…
<local:ListViewThreeColumns.ItemTemplate>
<DataTemplate>
<border:SfBorder Margin="{Binding ., Converter={StaticResource MarginConverter}, ConverterParameter={x:Reference listView}}"
BackgroundColor="{DynamicResource Gray-100}"
BorderColor="LightGray"
BorderWidth="1"
HeightRequest="{Binding Path=ItemSize, Source={x:Reference listView}}"
CornerRadius="13"
HasShadow="False">
<ffimageloading:CachedImage Source="{Binding ContactImage}"
BackgroundColor="{DynamicResource Gray-200}"
HeightRequest="{Binding Path=ItemSize, Source={x:Reference listView}}"
CacheDuration= "50"
RetryCount= "3"
RetryDelay= "500"
DownsampleToViewSize = "true"
Aspect="AspectFill" />
</border:SfBorder>
</DataTemplate>
</local:ListViewThreeColumns.ItemTemplate> |