Xaml 将ListViewItems显示为圆形
在列表视图中将项目显示为圆圈的最佳方式是什么? 我想在圆圈中嵌入项目的名称 我是否使用ItemContainerStyle 我假设我使用了一个controltemplate。但是,当我考虑它与ItInguleCultSype的关系时,我感到困惑。 以下代码有什么问题Xaml 将ListViewItems显示为圆形,xaml,windows-runtime,windows-store-apps,winrt-xaml,Xaml,Windows Runtime,Windows Store Apps,Winrt Xaml,在列表视图中将项目显示为圆圈的最佳方式是什么? 我想在圆圈中嵌入项目的名称 我是否使用ItemContainerStyle 我假设我使用了一个controltemplate。但是,当我考虑它与ItInguleCultSype的关系时,我感到困惑。 以下代码有什么问题 <ListView ItemsSource="{Binding Contacts}" CanDragItems="True" DragItemsStarting="OnDragItemStarting"&
<ListView ItemsSource="{Binding Contacts}"
CanDragItems="True" DragItemsStarting="OnDragItemStarting">
<ListViewItem Style="{StaticResource ContactsListItemStyle}" />
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<ContentControl Content="{Binding DisplayName}">
<ContentControl.Template>
<ControlTemplate>
<ContentControl>
<Grid>
<Ellipse Fill="LightGray" Height="50" Width="50" />
<Viewbox>
<ContentControl Margin="20" Content="{TemplateBinding Content}" />
</Viewbox>
</Grid>
</ContentControl>
</ControlTemplate>
</ContentControl.Template>
</ContentControl>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
以下XAML工作:
<Page.Resources>
<ControlTemplate x:Key="ContentControlTemplate" TargetType="ContentControl">
<ContentControl>
<Grid>
<Ellipse Fill="LightGray" Height="200" Width="200" />
<Viewbox>
<ContentControl Margin="20" Content="{TemplateBinding Content}" />
</Viewbox>
</Grid>
</ContentControl>
</ControlTemplate>
</Page.Resources>
<ListView ItemsSource="{Binding Contacts}"
CanDragItems="True" DragItemsStarting="OnDragItemStarting">
<ListViewItem Style="{StaticResource ContactsListItemStyle}" />
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<ContentControl Template="{StaticResource ContentControlTemplate}"
Content="{Binding DisplayName}" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
您必须设置ListView
的ItemTemplate
?应该会有帮助。用椭圆替换矩形(或用椭圆替换路径)。您的意思是希望列表以圆形布局显示吗?或者列表中的每一项都显示在一个排序的圆圈中?如果整个列表在一个圆圈中,您需要自己创建一个新的ItemsPanel。如果是后者,这将是您的ItemTemplate的一部分,如前所述。我希望列表中的每个项目都显示为一个圆圈。