2013-07-01 119 views
0

我有一个列表选择器,当点击控件选择另一个项目时,它看起来像是要工作,但全是白色的,我有时可以选择另一个项目,但不能看到选择什么,直到你离开它。这是我设置的方式。当我将其设置为完整模式时,名称空间是唯一不显示项目实际名称的东西。我想要做的是加载视图我需要加载listPicker的值。列表选取器未显示项目。

<phone:PhoneApplicationPage.Resources> 
    <DataTemplate x:Name="PickerItemTemplate" > 
     <StackPanel Orientation="Horizontal"> 
      <TextBlock Text="{Binding TankTypeName}" Style="{StaticResource PhoneTextNormalStyle}"/> 
     </StackPanel> 
    </DataTemplate> 
    <DataTemplate x:Name="PickerFullModeItemTemplate"> 
     <StackPanel Orientation="Horizontal"> 
      <TextBlock Text="{Binding TankTypeName}" Style="{StaticResource PhoneTextNormalStyle}" FontFamily="{StaticResource PhoneFontFamilyLight}"/> 
     </StackPanel> 
    </DataTemplate> 
</phone:PhoneApplicationPage.Resources> 


<!--ContentPanel - place additional content here--> 
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> 
    <TextBox Height="72" HorizontalAlignment="Left" Margin="0,50,0,0" Name="TextBoxProjectName" Text="" VerticalAlignment="Top" Width="456" /> 
    <TextBlock Height="30" HorizontalAlignment="Left" Margin="12,28,0,0" Name="TextBlockProjectName" Text="Tank Name:" VerticalAlignment="Top" /> 
    <toolkit:ListPicker Header="Tank Type:" ItemsSource="{Binding TankTypes}" 
          ItemTemplate="{StaticResource PickerItemTemplate}" 
          FullModeItemTemplate="{Binding PickerFullModeItemTemplate}" 
          SelectedItems="{Binding SelectedTankTypes,Mode=TwoWay}" 

          Height="100" HorizontalAlignment="Left" 
          Margin="6,144,0,0" Name="ListPickerTankType" 
          VerticalAlignment="Top" Width="444" > 
    </toolkit:ListPicker> 
</Grid> 

视图模型

private List<TankType> _tankType; 

private ObservableCollection<Object> _selectedTankType= new ObservableCollection<object>(); 

    /// <summary> 
    /// Collection of Tank Type objects. 
    /// </summary> 
public List<TankType> TankTypes 
{ 
    get 
    { 
     return _tankType; 
    } 

    set 
    { 
     if (value != _tankType) 
     { 
      _tankType = value; 
      NotifyPropertyChanged("TankType"); 
     } 
    } 
} 


public ObservableCollection<object> SelectedTankTypes 
{ 
    get 
    { 
     return _selectedTankType; 
    } 

    set 
    { 
     if (_selectedTankType == value) 
     { 
      return; 
     } 

     _selectedTankType = value; 
     NotifyPropertyChanged("SelectedTankTypes"); 
    } 
} 

这是一个编辑页面,以便在视图的构造函数。

public TaskDetail() 
{ 
    InitializeComponent(); 
    var tankTypeViewModel = new ViewModels.TankVewModel(); 
    tankTypeViewModel.GetTankTypes(); 
    ListPickerTankType.DataContext = tankTypeViewModel; 
} 

修正OK我删除了listpicker上的高度,现在可以看到它变大了,所以三个项目在那里。我似乎无法将字体颜色更改为黑色,因此当您单击列表选择器时,我可以看到它。

回答

0

想通了。我需要删除高度并将前景色设置为黑色。