0
我爲ListViewItem創建了一個模板。ListView ItemTemplate未填充
它沒有填滿所有空格。
我的模板如下:
<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的設計師看到:
感謝,以及似乎工作,但是,邊界標記,開始時看不到它,但進一步幾個像素,爲什麼? –
我已經編輯了我的答案和更多關於此的信息。 –
感謝:D的幫助 –