我为ListViewItem创建了一个模板。
它没有填满所有空格。
我的模板如下:
<UserControl
x:Class="AgendaUWP.Styles.Template.ItemTemplateContatti"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AgendaUWP.Styles.Template"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="100"
d:DesignWidth="400">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border Background="CornflowerBlue" Grid.Column="0" Width="3" Margin="0 0 0 0" VerticalAlignment="Stretch"/>
<StackPanel Grid.Column="1" Orientation="Vertical" Margin="10 0 0 0" HorizontalAlignment="Stretch" VerticalAlignment="Center" >
<TextBlock Text="{Binding Tipo}" FontWeight="Thin" FontSize="10" TextAlignment="Center" />
<TextBlock Text="{Binding Descrizione}" FontWeight="SemiBold" FontSize="16" TextAlignment="Center"/>
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Vertical" VerticalAlignment="Center" HorizontalAlignment="Stretch" >
<StackPanel Orientation="Horizontal" Margin="0 10 0 10" >
<SymbolIcon Symbol="Phone" Margin="10 0 10 0"></SymbolIcon>
<TextBlock Text="{Binding Telefono}" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 10 0 10">
<SymbolIcon Symbol="Mail" Margin="10 0 10 0"></SymbolIcon>
<TextBlock Text="{Binding Email}" />
</StackPanel>
</StackPanel>
</Grid>
这是用它的方式:
<ListView x:Name="listaContatti"
IsItemClickEnabled="True" MaxHeight="200"
SelectedItem="{Binding ClientiContatti,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
ItemsSource="{Binding ListaClientiContatti,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}">
<ListView.ItemTemplate>
<DataTemplate>
<template:ItemTemplateContatti />
</DataTemplate>
</ListViewItemTemplate>
</ListView>
这是我的结果:
我想看到线条的开头,边框蓝色和两个StackPanel,正如您在visual studio designer中看到的那样:
答案 0 :(得分:1)
尝试将每个HorizontalContentAlignment
的{{1}}设置为ListViewItem
。同时将Stretch
设置为Padding
以删除蓝色条之前的间隙。
0