2014-01-29 170 views
0

我有follwing listpickerListpicker文本對齊向右

<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個項目,我想他們需要右對齊,但由於某些原因,我無法找到對齊文本的選項,我錯過了什麼?

回答

1

您應該在ListPickerItemTemplate中執行此操作。添加模板頁面資源(或應用程序資源)

<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> 

,並指定模板選取器:使用的ItemsSource =「{結合稱號}」這是一個列表 對象

<toolkit:ListPicker 
    ItemTemplate="{StaticResource ListPickerItemTemplate}" 
    FullModeItemTemplate="{StaticResource ListPickerFullModeItemTemplate}" 
... 
+0

IM,什麼會我在這些字段中設置了Text =「{Binding ItemName}」您的代碼? – Ric

+0

使用'Text =「{Binding}」'。 – crea7or

+0

嗯,項目顯示,但他們仍然對齊左:\ http://oi59.tinypic.com/2ms1u11.jpg像這樣 – Ric