Полноэкранный фон списка выбора Windows Phone 8

Я пытаюсь установить фон в полном режиме моего списка. Я видел это: http://www.geekchamp.com/tips/listpicker-fullscreen-mode-background-problem-workaround, но, похоже, это не работает с Windows Phone 8 ListPicker, поскольку шаблоны разные?

Вот мой шаблон:

    <ControlTemplate x:Key="ListPickerControlTemplate" TargetType="toolkit:ListPicker">
    <StackPanel>
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="PickerStates">
                <VisualState x:Name="Normal">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames
                            Storyboard.TargetName="Header"
                            Storyboard.TargetProperty="Foreground"
                            Duration="0">
                            <DiscreteObjectKeyFrame
                                Value="{StaticResource AppDefaultBlueColor}"
                                KeyTime="0"/>
                            </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                    </VisualState>
                <VisualState x:Name="Highlighted">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames
                            Storyboard.TargetName="UserControl"
                            Storyboard.TargetProperty="Foreground"
                            Duration="0">
                            <DiscreteObjectKeyFrame
                                Value="{StaticResource PhoneTextBoxForegroundBrush}"
                                KeyTime="0"/>
                        </ObjectAnimationUsingKeyFrames>
                        <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>
                        <ObjectAnimationUsingKeyFrames
                            Storyboard.TargetName="Header"
                            Storyboard.TargetProperty="Foreground"
                            Duration="0">
                            <DiscreteObjectKeyFrame
                                Value="{StaticResource AppDefaultBlueColor}"
                                KeyTime="0"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="Disabled">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames
                            Storyboard.TargetName="Border"
                            Storyboard.TargetProperty="Background"
                            Duration="0">
                            <DiscreteObjectKeyFrame
                                Value="{StaticResource TransparentBrush}"
                                KeyTime="0"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames
                            Storyboard.TargetName="Border"
                            Storyboard.TargetProperty="BorderBrush"
                            Duration="0">
                            <DiscreteObjectKeyFrame
                                Value="{StaticResource PhoneDisabledBrush}"
                                KeyTime="0"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames
                            Storyboard.TargetName="UserControl"
                            Storyboard.TargetProperty="Foreground"
                            Duration="0">
                            <DiscreteObjectKeyFrame
                                Value="{StaticResource PhoneDisabledBrush}"
                                KeyTime="0"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames
                            Storyboard.TargetName="Header"
                            Storyboard.TargetProperty="Foreground"
                            Duration="0">
                            <DiscreteObjectKeyFrame
                                Value="{StaticResource PhoneDisabledBrush}"
                                KeyTime="0"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <ContentControl
        x:Name="Header"
            Content="{TemplateBinding Header}"
            ContentTemplate="{TemplateBinding HeaderTemplate}"
            Foreground="{StaticResource AppDefaultBlueColor}"
            FontSize="{StaticResource PhoneFontSizeNormal}"
            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
            Margin="0 0 0 8"/>
        <Grid >
            <Border x:Name="Border"
                Background="{TemplateBinding Background}"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}">
                <UserControl x:Name="UserControl" Foreground="{TemplateBinding Foreground}">
                    <StackPanel>
                        <TextBlock x:Name="MultipleSelectionModeSummary" Margin="8 8 0 8" />
                        <Canvas x:Name="ItemsPresenterHost" MinHeight="46">
                            <ItemsPresenter x:Name="ItemsPresenter">
                                <ItemsPresenter.RenderTransform>
                                    <TranslateTransform x:Name="ItemsPresenterTranslateTransform"/>
                                </ItemsPresenter.RenderTransform>
                            </ItemsPresenter>
                        </Canvas>
                    </StackPanel>
                </UserControl>
            </Border>
        </Grid>
    </StackPanel>
</ControlTemplate>

person robertk    schedule 18.11.2013    source источник
comment
какие проблемы у тебя возникают?   -  person techloverr    schedule 18.11.2013
comment
Проблема в том, что я не могу понять, как изменить фон fullmode-popup в шаблоне.   -  person robertk    schedule 18.11.2013


Ответы (2)


Надеюсь, это поможет вам. Просто добавьте следующую строку в конструктор файла App.xaml.cs:

((SolidColorBrush)App.Current.Resources["PhoneChromeBrush"]).Color = GetColorFromHexa("#1589FF").Color;

///Conert hexa decimal color value to solidcolorBrush
SolidColorBrush GetColorFromHexa(string hexaColor) 
{
    byte r = Convert.ToByte(hexaColor.Substring(1, 2), 16);
    byte g = Convert.ToByte(hexaColor.Substring(3, 2), 16);
    byte b = Convert.ToByte(hexaColor.Substring(5, 2), 16);
    SolidColorBrush soliColorBrush = new SolidColorBrush(Color.FromArgb(0xFF, r, g, b));
    return soliColorBrush;
}
person Jaihind    schedule 18.11.2013
comment
Кажется, работает. Но в таком случае как изменить цвет заголовка? Это белый банкомат, и я хочу, чтобы фон был белым, что делает его невидимым. - person robertk; 18.11.2013
comment
Изменить шаблон заголовка - person Shawn Kendrot; 21.11.2013

Вы можете клонировать ListPickerPage.xaml, найденный в исходном коде Toolkit, изменить все, что вам нравится, и настроить ListPicker::PickerPageUri так, чтобы он указывал на вашу собственную копию ListPickerPage.

person atomaras    schedule 19.11.2013