2012-02-27 2 views
0

응용 프로그램 표시 줄에 아이콘 단추를 추가하면 어두운 테마를 사용중인 경우 아이콘이 흰색으로 표시되고 밝은 테마가 사용중인 경우 아이콘이 검은 색으로 표시됩니다. 신청서의 다른 곳에이 자동 색소를 사용할 수 있습니까? SDK 디렉토리에서 아이콘 이미지를 가져 와서 일반 버튼에서 사용하고 싶습니다. 주제에 따라 흰색 또는 검정색 중 하나를 표시 할 수 있다면 좋을 것입니다. 지금은 수동으로 변환기를 사용하고 있지만 자동으로 처리하는 방법이 있다면 좀 더 깨끗합니다. 누구든지 방법을 알고 있습니까?WP7의 다른 곳에서 자동 아이콘 채색의 응용 프로그램 막대 스타일?

답변

3
<Button Background="{StaticResource PhoneContrastBackgroundBrush}" > 
    <Button.OpacityMask> 
     <ImageBrush ImageSource="/Images/icon.png"/> 
    </Button.OpacityMask> 
</Button> 

icon.png 흰색이어야

[EDIT]

OR (주위의 원을 그려) SDK 이미지 (appbar.basecircle.rest.png)

<Style x:Key="FlatStyle" TargetType="Button"> 
      <Setter Property="Background" Value="Transparent"/> 
      <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/> 
      <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/> 
      <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/> 
      <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/> 
      <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/> 
      <Setter Property="Padding" Value="10,3,10,5"/> 
      <Setter Property="Template"> 
       <Setter.Value> 
        <ControlTemplate TargetType="Button"> 
         <Grid Background="Transparent"> 
          <VisualStateManager.VisualStateGroups> 
           <VisualStateGroup x:Name="CommonStates"> 
            <VisualState x:Name="Normal"/> 
            <VisualState x:Name="MouseOver"/> 
            <VisualState x:Name="Pressed"> 
             <Storyboard> 
              <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer"> 
               <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneBackgroundBrush}"/> 
              </ObjectAnimationUsingKeyFrames> 
              <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground"> 
               <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneForegroundBrush}"/> 
              </ObjectAnimationUsingKeyFrames> 
              <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground"> 
               <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneForegroundBrush}"/> 
              </ObjectAnimationUsingKeyFrames> 
             </Storyboard> 
            </VisualState> 
            <VisualState x:Name="Disabled"> 
             <Storyboard> 
              <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer"> 
               <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/> 
              </ObjectAnimationUsingKeyFrames> 
              <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground"> 
               <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/> 
              </ObjectAnimationUsingKeyFrames> 
              <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground"> 
               <DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/> 
              </ObjectAnimationUsingKeyFrames> 
             </Storyboard> 
            </VisualState> 
           </VisualStateGroup> 
          </VisualStateManager.VisualStateGroups> 
          <Border x:Name="ButtonBackground" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="0" Margin="{StaticResource PhoneTouchTargetOverhang}"> 
           <Grid> 
            <Canvas Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"> 
             <Rectangle Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Fill="{StaticResource PhoneForegroundBrush}"> 
              <Rectangle.OpacityMask> 
               <ImageBrush ImageSource="/appbar.basecircle.rest.png"/> 
              </Rectangle.OpacityMask> 
             </Rectangle> 
             <Rectangle Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" Fill="{StaticResource PhoneForegroundBrush}" OpacityMask="{TemplateBinding BorderBrush}"/> 
            </Canvas> 
            <ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/> 
           </Grid> 

          </Border> 
         </Grid> 
        </ControlTemplate> 
       </Setter.Value> 
      </Setter> 
     </Style> 
를 사용

용도 :

<Button Style="{StaticResource FlatStyle}" BorderThickness="0" Width="48" Height="48"> 
       <Button.BorderBrush> 
        <ImageBrush ImageSource="/appbar.favs.rest.png"/> 
       </Button.BorderBrush> 
      </Button> 
+0

굉장합니다, 고마워요. 이 기법을 사용하면서 어떻게 서로의 위에 2 개의 이미지를 쌓을 수 있는지에 대한 아이디어는 있습니까? SDK와 함께 제공되는 체크 및 취소 이미지를 사용하고 있으며 SDK 주변에 원이 그려져 있습니다 (SDK와 함께 제공된 원 이미지를 사용하고있었습니다). – Zik

+0

각 이미지의 'Visible' 속성을 처리하십시오. – Ku6opr

+0

버튼 스타일을 선언하고 사용해야합니다. 내 게시물 변경 내용을 참조하십시오 – ebattulga

관련 문제