음악 플레이어의 재생 및 일시 중지 단추와 같은 단추를 가져 오는 RoundButtonTemplate이 있습니다. 버튼을 전경색과 배경색을 변경해야 ContentPresenter에를 통해 표시 또는 투명성을 얻을 수있는 아이콘으로 변경해야합니다 버튼의 배경을 누르면RoundButtonTemplate 변경된 배경 및 아이콘 색상
<ControlTemplate x:Key="RoundButtonTemplate" TargetType="Button">
<Grid Background="Transparent" Margin="{StaticResource PhoneTouchTargetOverhang}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill)" Storyboard.TargetName="ButtonBackground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneAccentBrush}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Normal"/>
<VisualState x:Name="Disabled">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Opacity)" Storyboard.TargetName="ButtonBackground">
<DiscreteObjectKeyFrame KeyTime="0" Value="0.5"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Opacity)" Storyboard.TargetName="ButtonBorder">
<DiscreteObjectKeyFrame KeyTime="0" Value="0.5"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Opacity)" Storyboard.TargetName="ButtonContent">
<DiscreteObjectKeyFrame KeyTime="0" Value="0.5"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="MouseOver"/>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates"/>
</VisualStateManager.VisualStateGroups>
<Border x:Name="ButtonBorder" BorderBrush="White" BorderThickness="3" Background="Transparent" CornerRadius="100">
<Ellipse x:Name="ButtonBackground" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Fill="{TemplateBinding Background}" />
</Border>
<ContentPresenter x:Name="ButtonContent" Content="{TemplateBinding Content}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
.
버튼의 배경을 전경색으로 변경하는 것은 쉽지만 ContentPresenter에서 이미지의 색상을 변경하는 방법을 모르겠습니다.
왜 왜 이미지 자체를 변경하지, 당신은 이미지의 색상을 변경하려면 해당이 가능할 수 있다고 생각합니까를 해결? – AymenDaoudi
예를 들어 버튼 배경을 흰색으로 설정하고 이미지 색상을 검정색 또는 투명으로 설정하려고합니다. 이미지 위에 놓이는 불투명 마스크로 가능하지만 ContentPresenter 또는 ContentControl에서 설정하는 방법을 모르겠습니다. –
이미지 자체를 변경하면 더 간단 해집니다. – AymenDaoudi