无法自定义工具包:listpicker FullMode

时间:2014-03-09 08:10:14

标签: silverlight xaml windows-phone-7 windows-phone-8 listpicker

我正在尝试在FullMode中自定义工具包:listpicker,但无论我做什么,它总是与手机主题相同(黑色背景上的白色文字和标记项目上的红色)。

我的xaml是这样的:

<UserControl.Resources>
    <Style TargetType="toolkit:ListPicker" x:Key="StyledListPicker">
        <Setter Property="Background" Value="{StaticResource MainColor}"/>
        <Setter Property="Foreground" Value="{StaticResource SecondColor}"/>
        <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeLarge}"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="Margin" Value="{StaticResource PhoneTouchTargetOverhang}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="toolkit:ListPicker">
                    <StackPanel>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="PickerStates">
                                <VisualState x:Name="Normal"/>
                                <VisualState x:Name="Expanded">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames
                                        Storyboard.TargetName="Border"
                                        Storyboard.TargetProperty="Background"
                                        Duration="0">
                                            <DiscreteObjectKeyFrame
                                            Value="{StaticResource PhoneTextBoxEditBackgroundColor}"
                                            KeyTime="0"/>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentControl
                        Content="{TemplateBinding Header}"
                        ContentTemplate="{TemplateBinding HeaderTemplate}"
                        Foreground="{StaticResource PhoneSubtleBrush}"
                        FontSize="{StaticResource PhoneFontSizeNormal}"
                        HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                        Margin="0 0 0 8"/>
                        <Grid>
                            <Border
                            x:Name="Border"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding Background}"
                            BorderThickness="2">
                                <Canvas x:Name="ItemsPresenterHost" MinHeight="46">
                                    <ItemsPresenter x:Name="ItemsPresenter">
                                        <ItemsPresenter.RenderTransform>
                                            <TranslateTransform x:Name="ItemsPresenterTranslateTransform"/>
                                        </ItemsPresenter.RenderTransform>
                                    </ItemsPresenter>
                                </Canvas>
                            </Border>
                            <Popup x:Name="FullModePopup">
                                <Border Background="Red">
                                    <Grid Background="Green">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto"/>
                                            <RowDefinition/>
                                        </Grid.RowDefinitions>
                                        <ContentControl
                                            Grid.Row="0"
                                            Background="Blue"
                                            Content="Dupa"
                                            Foreground="{StaticResource SecondColor}"
                                            FontFamily="{StaticResource PhoneFontFamilySemiBold}"
                                            FontSize="{StaticResource PhoneFontSizeLarge}"
                                            HorizontalAlignment="Right"
                                            Margin="24 12 0 0"/>
                                        <ListBox
                                            Background="Orange"
                                            x:Name="FullModeSelector"
                                            Grid.Row="1"
                                            ItemTemplate="{TemplateBinding FullModeItemTemplate}"
                                            FontSize="{TemplateBinding FontSize}"
                                            Margin="{StaticResource PhoneMargin}">
                                            <ListBox.ItemsPanel>
                                                <ItemsPanelTemplate>
                                                    <StackPanel Background="Yellow">
                                                    </StackPanel>
                                                </ItemsPanelTemplate>
                                            </ListBox.ItemsPanel>
                                        </ListBox>
                                    </Grid>
                                </Border>
                            </Popup>
                        </Grid>
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</UserControl.Resources>

和ListPicker

<toolkit:ListPicker x:Name="Categories"
                Grid.Column="1" 
                Style="{StaticResource StyledListPicker}"/>

WP 7和8上出现问题

请指导我这里遗漏的内容,我确实从网上复制了几个例子并且它们不起作用(全屏的样式不会改变)。

我发现了这个:ListPicker FullMode Selected Item Color但是我真的需要一个新的xaml来改变控件颜色吗?

0 个答案:

没有答案