私はあなたがデフォルトの区切りを無効にし、これらはいくつかのヒントです
まずthis post
に見てみることができ、これが後のListView XAML
SeparatorColor="Transparent"
に次のプロパティを追加することによって行われていると思いますこれは、ダブルStackLayoutの中に完全なViewCellコンテンツをラップします!私はこれが過度のように聞こえるが、この方法では、ViewCell ...または他のものの内部の余白に関するBoxViewの問題に遭遇することはないだろう。 最初のStackLayoutは、区切り記号を設定する色にBackgroundColorを設定する必要があります.2番目のStackLayoutは、この例のページでは、残りのコンテナと同じBackgroundColorを持つ必要があります。この2番目のStackLayoutの下に余白を追加するのは、セパレータの太さを表すためです。
は、私はあなたがこの「証拠金」...あなたのデータが空になったときに、代わりにそれとセパレーター
<ListView x:Name="SeparatorListView"
SeparatorColor="Transparent"
ItemsSource="{Binding Persons}"
Margin="0,20,0,0"
RowHeight="60"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
BackgroundColor="White"
Grid.Row="1">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell IsEnabled="false">
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"
BackgroundColor="Black">
<StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"
BackgroundColor="White"
Margin="0,0,0,0.4">
<StackLayout VerticalOptions="CenterAndExpand" HorizontalOptions="FillAndExpand" Spacing="0">
<Label Text="{Binding FullName}" TextColor="Maroon" VerticalOptions="CenterAndExpand" Margin="20,0,20,0" />
<Label Text="{Binding Profession}" TextColor="Maroon" VerticalOptions="CenterAndExpand" Margin="20,0,20,0" />
</StackLayout>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
を持つべきではありませんので、余裕を削除すると遊ぶことができると思い、あなたが買ってあげますこのブログ記事の右上にあるプレビュー画像と同じ視覚的な結果です。
ボーナスとして、あなたのページに白以外の背景色がある場合は、StackLayoutsの1つを省略することができます。これが当てはまる場合、ListViewの内部で透明で再生することで、その色をセパレータの色として使用できます。
この例では、ページ自体にもOlive!に設定されたBackgroundColorがある場合にのみ、ノートが機能します。
<ListView x:Name="SeparatorListView"
SeparatorColor="Transparent"
ItemsSource="{Binding Persons}"
Margin="0,20,0,0"
RowHeight="60"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"
BackgroundColor="Olive"
Grid.Row="1">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell IsEnabled="false">
<StackLayout BackgroundColor="#f4eac3"
Padding="0,5,0,5"
HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
<StackLayout BackgroundColor="Transparent"
HorizontalOptions="FillAndExpand" VerticalOptions="CenterAndExpand"
Spacing="0"
Margin="20,0,20,0">
<Label Text="{Binding FullName}" TextColor="Maroon" VerticalOptions="CenterAndExpand" />
<Label Text="{Binding Profession}" TextColor="Maroon" VerticalOptions="CenterAndExpand" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
おかげ@AlessandroCaliaro!私のページのBackgroundImageを持っていて、ListViewに 'BackgroundColor =" Transparent "があるので、私はうまくいきませんでした。そのトリックはできませんでした。 私のSeparatorVisibility = "None"を作成し、私のSeparatorをシミュレートしたBackgroundColorを使ってグリッドに追加する(私は各ViewCellの中に1つずつ)それは完璧に動作します、ありがとう! –