2

누구나 ListPicker의 FullMode에서 배경을 쉽게 변경하는 방법을 알고 있습니까? 그것을 할 수있는 스타일을 설정해야합니까? 나는 그것을 시도했으나 배경을 설정할 적절한 위치를 찾지 못했습니다 ... 사용되어야하는 스타일이라면 정확히 그 스타일로 배경을 설정할 수 있습니까? 어떤 도움은 매우 극명하게 될 것이다 : 여기 WP7에서 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> 

답변

1

이 템플릿을 통해이 작업을 수행 할 수있는 방법이 없습니다.

이렇게하는 유일한 방법은 컨트롤 소스를 변경하는 것입니다. TargetType="controls:ListPicker"에 대해 Style을 변경해야합니다.

특히 FullModePopup의 내용을 변경해야합니다.

+1

그래, 내가 스타일을 변경해야 할 것을 알고 있지만, 어디 스타일? 나는 배경을 도처에 설정하려했지만, 배경이 무엇인지 알아낼 수는 없다. 1 기둥에 스타일을 게시 할 수 있고, 배경을 바꿀 수있는 곳을 정확히 지적 할 수 있을까? – kgrevehagen

1

나는이 똑같은 것을 궁금해하고 있었다.

ListPicker의 배경색을 직접 변경하는 방법은 없지만 PhoneChromeBrush 자원의 색상과 함께 따라 가기 때문에 앱의 모든 색상을 재정 의하여 색상을 변경할 수 있습니다. 이 배경. 예를 들어

:

((SolidColorBrush)App.Current.Resources["PhoneChromeBrush"]).Color = Colors.Cyan;