Windows phone 8 listpicker中的颜色选择器使用

Windows phone 8 listpicker中的颜色选择器使用,windows-phone-8,color-picker,listpicker,Windows Phone 8,Color Picker,Listpicker,我试图在Windows Phone 8上使用颜色选择器,但我看不到颜色。我不明白我在哪里犯了错误 这是我的数据透视页代码: string[] colorNames = { "GreenYellow","Lime","Chartreuse","LimeGreen","SpringGreen","LightGreen" } uint[] uintColors = { 0xFFFFFF00,0xFFFFE13

我试图在Windows Phone 8上使用颜色选择器,但我看不到颜色。我不明白我在哪里犯了错误

这是我的数据透视页代码:

  string[] colorNames =
        {
         "GreenYellow","Lime","Chartreuse","LimeGreen","SpringGreen","LightGreen"
        }
  uint[] uintColors =
        {
          0xFFFFFF00,0xFFFFE135,0xFFFFFF66,0xFFF8DE7E,0xFF008000,0xFF008A00
        }

  List<ColorItem> item = new List<ColorItem>();
         for (int i = 0; i < 6; i++)
         {
             item.Add(new ColorItem() { Text = colorNames[i], Color =  ConvertColor(uintColors[i]) });
         };


        listPicker.ItemsSource = item; //Fill ItemSource with all colors

    }

    private Color ConvertColor(uint p)
    {

         byte A = (byte)((p & 0xFF000000) >> 24);
         byte R = (byte)((p & 0x00FF0000) >> 16);
         byte G = (byte)((p & 0x0000FF00) >> 8);
         byte B = (byte)((p & 0x000000FF) >> 0);

         return Color.FromArgb(A, R, G, B); ;
    }
像这样:

这是:


您遗漏了实际构建彩色正方形的xaml。看



标题的含义不清楚。很抱歉。我的英语并不完美。
class ColorItem
{
    public string Text { get; set; }
    public Color Color { get; set; }
}
<phone:PhoneApplicationPage
x:Class="CustomColorsPicker.ColorPickerPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="False"
xmlns:converters="clr-namespace:CustomColorsPicker.Converters"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
toolkit:TiltEffect.IsTiltEnabled="True">

<phone:PhoneApplicationPage.Resources>
    <converters:ColorToBrushConverter x:Key="ColorToBrushConverter"/>
</phone:PhoneApplicationPage.Resources>

<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <!--ContentPanel - place additional content here-->
    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

        <ListBox Name="listBox" SelectionChanged="lstColor_SelectionChanged">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <toolkit:WrapPanel/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>

            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel x:Name="item" Orientation="Horizontal" Margin="12, 6 0, 6">
       <Rectangle Fill="{Binding Color, Converter={StaticResource ColorToBrushConverter}}" 
                            Width="100" Height="100" />
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

    </Grid>
</Grid>

</phone:PhoneApplicationPage>