2013-06-12 29 views
1

我有一個Windows Phone 8應用程序。我的應用程序使用Toolkit中的ListPicker。我的應用顯示得很好。但是,當我展開ListPicker時,背景是白色。我無法讀取任何項目的文字。當ListPicker被摺疊時,我可以很好地讀取所選項目的文本。這裏是我的代碼:Windows Phone工具包ListPicker背景爲白色

<Grid x:Name="myGrid" Background="Black" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"> 
    <Grid.RowDefinitions> 
    <RowDefinition Height="Auto" />      
    <RowDefinition Height="*" /> 
    </Grid.RowDefinitions> 

    <Grid.RenderTransform> 
    <TranslateTransform x:Name="myGridTransform" /> 
    </Grid.RenderTransform> 

    <Grid Background="Silver" VerticalAlignment="Stretch"> 
    <Grid.RowDefinitions> 
     <RowDefinition Height="Auto" /> 
     <RowDefinition Height="Auto" /> 
    </Grid.RowDefinitions> 

    <TextBlock Text="app name" Margin="24,6,0,0" Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" HorizontalAlignment="Left" Style="{StaticResource PhoneTextSmallStyle}" /> 
    <TextBlock Text="PAGE" Margin="24,0,0,6" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2" HorizontalAlignment="Left" Style="{StaticResource PhoneTextLargeStyle}" /> 
    </Grid> 

    <ScrollViewer Grid.Row="1" Margin="8,0,8,0"> 
    <Grid> 
     <Grid.RowDefinitions> 
     <RowDefinition Height="Auto" /> 
     <RowDefinition Height="Auto" /> 
     <RowDefinition Height="Auto" /> 
     <RowDefinition Height="Auto" /> 
     </Grid.RowDefinitions> 

     <TextBlock HorizontalAlignment="Left" Grid.Row="0" TextWrapping="Wrap" Text="Group" VerticalAlignment="Top" Style="{StaticResource PhoneTextGroupHeaderStyle}" Margin="12,12,12,0" /> 
     <TextBlock HorizontalAlignment="Left" Grid.Row="1" TextWrapping="Wrap" Text="label" VerticalAlignment="Top" Style="{StaticResource PhoneTextLargeStyle}"/> 
     <toolkit:ListPicker x:Name="myListPicker" Grid.Row="2" Margin="12,-6,12,-2" Background="Transparent" Loaded="myListPicker_Loaded"> 
     <toolkit:ListPicker.Items> 
      <toolkit:ListPickerItem Tag="1" Content="Option 1" /> 
      <toolkit:ListPickerItem Tag="2" Content="Option 2" /> 
     </toolkit:ListPicker.Items> 
     </toolkit:ListPicker> 
     <TextBlock HorizontalAlignment="Left" Grid.Row="3" Margin="12,0,12,8" TextWrapping="Wrap" Text="other details." VerticalAlignment="Top" Style="{StaticResource PhoneTextSmallStyle}" /> 
    </Grid> 
    </ScrollViewer> 
</Grid> 

我在做什麼錯?

+0

這可能是由工具包的錯誤引起的。它可以通過將ListPicker的ItemsSource綁定到ObservableCollection來解決 – Hong

回答

0

我認爲,這是因爲你在輕主題

設備或模擬器嘗試更新擴展可視化狀態的背景

0

而不是使用屬性內容,添加ListPickerItem的文本標籤本身usinf。就像這樣:

<toolkit:ListPicker x:Name="myListPicker"> 
    <sys:String>Option 1</sys:String> 
    <sys:String>Option 2</sys:String> 
</toolkit:ListPicker> 
0

我面對這個問題,ListBox在後臺使用去黑上增加ListBox高度。問題在於父容器。不知何故,當上下文超過特定高度時,Grid的孩子不會遵守背景顏色。嘗試將Grid替換爲StackPanel作爲父容器,並將每個孩子的背景顏色設置爲所需的顏色。應該管用。

相關問題