2

ListPicker の FullMode で背景を簡単に変更する方法を知っている人はいますか? それができるようにスタイルを設定する必要がありますか? 試してみましたが、背景を設定する適切な場所が見つかりません...使用する必要があるスタイルの場合、そのスタイルのどこに背景を設定できますか? どんな助けでも大歓迎です:)

ListPicker の標準スタイルは次のとおりです。

<Style TargetType="toolkit:ListPicker"> 
    <Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}"/> 
    <Setter Property="Foreground" Value="{StaticResource PhoneTextBoxForegroundBrush}"/> 
    <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/> 
    <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> 
                                    <ObjectAnimationUsingKeyFrames 
                                        Storyboard.TargetName="Border" 
                                        Storyboard.TargetProperty="BorderBrush" 
                                        Duration="0"> 
                                        <DiscreteObjectKeyFrame 
                                            Value="{StaticResource PhoneTextBoxEditBorderBrush}" 
                                            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="{StaticResource PhoneChromeBrush}"> <!-- Popup.Child should always be a Border --> 
                                <Grid> 
                                    <Grid.RowDefinitions> 
                                        <RowDefinition Height="Auto"/> 
                                        <RowDefinition/> 
                                    </Grid.RowDefinitions> 
                                    <ContentControl 
                                        Grid.Row="0" 
                                        Content="{TemplateBinding FullModeHeader}" 
                                        Foreground="{StaticResource PhoneForegroundBrush}" 
                                        FontFamily="{StaticResource PhoneFontFamilySemiBold}" 
                                        FontSize="{StaticResource PhoneFontSizeMedium}" 
                                        HorizontalAlignment="Left" 
                                        Margin="24 12 0 0"/> 
                                    <ListBox 
                                        x:Name="FullModeSelector" 
                                        Grid.Row="1" 
                                        ItemTemplate="{TemplateBinding ActualFullModeItemTemplate}" 
                                        FontSize="{TemplateBinding FontSize}" 
                                        Margin="{StaticResource PhoneMargin}"> 
                                        <ListBox.ItemsPanel> 
                                            <ItemsPanelTemplate> 
                                                <StackPanel/> <!-- Ensures all containers will be available during the Loaded event --> 
                                            </ItemsPanelTemplate> 
                                        </ListBox.ItemsPanel> 
                                    </ListBox> 
                                </Grid> 
                            </Border> 
                        </Popup> 
                    </Grid> 
                </StackPanel> 
            </ControlTemplate> 
        </Setter.Value> 
    </Setter> 
</Style>
4

2 に答える 2

1

テンプレートを使用してこれを行う方法はありません。

これを行う唯一の方法は、コントロールのソースを変更することです。Style( forを変更する必要がありますTargetType="controls:ListPicker"。)

具体的には、の内容を変更する必要がありますFullModePopup

于 2011-09-29T15:51:19.653 に答える
1

私はこれと同じことを疑問に思っていました。

の背景色を直接変更する方法はありませんListPickerが、リソースの色に従っているためPhoneChromeBrush、アプリ内のすべての色をオーバーライドして、この背景の色を変更できます。

例えば:

((SolidColorBrush)App.Current.Resources["PhoneChromeBrush"]).Color = Colors.Cyan;
于 2013-03-18T21:56:24.500 に答える