我有以下listpicker
<toolkit:ListPicker ItemsSource="{Binding title}" Name="titlePicker" ExpansionMode="ExpansionAllowed" Grid.Row="1" Margin="0,-50,50,0" Background="White" Foreground="#FFDA3434" Canvas.ZIndex="10" HorizontalAlignment="Right" FontSize="20" Grid.RowSpan="2"/>
包含3个项目,我希望它们对齐,但由于某种原因,我找不到对齐文本的选项,我缺少什么?
答案 0 :(得分:1)
您应该在ListPicker ItemTemplate中执行此操作。将模板添加到页面资源(或应用程序资源)
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Name="ListPickerItemTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock HorizontalAlignment="Right" Text="{Binding ItemName}"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Name="ListPickerFullModeItemTemplate">
<StackPanel Orientation="Horizontal">
<TextBlock HorizontalAlignment="Right" Text="{Binding ItemName}"/>
</StackPanel>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
并将模板分配给选择器:
<toolkit:ListPicker
ItemTemplate="{StaticResource ListPickerItemTemplate}"
FullModeItemTemplate="{StaticResource ListPickerFullModeItemTemplate}"
...