Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It seems like you're looking for the RadioButton functionality on a couple of Buttons. In that case, you can just re-template a RadioButton with the default Button-Template and add the VisualState for Checked. This example will make the Background turn Red for the latest Clicked Button, I hope that's what you're after</p> <pre><code>&lt;StackPanel&gt; &lt;RadioButton Style="{StaticResource RadioButtonStyle1}" GroupName="buttonGroup" HorizontalContentAlignment="Center" Content="Some Button"/&gt; &lt;RadioButton Style="{StaticResource RadioButtonStyle1}" GroupName="buttonGroup" HorizontalContentAlignment="Center" Content="Some Button 2"/&gt; &lt;/StackPanel&gt; </code></pre> <p>And the RadioButtonStyle1</p> <pre><code>&lt;Style x:Key="RadioButtonStyle1" TargetType="RadioButton"&gt; &lt;Setter Property="Background" Value="Transparent"/&gt; &lt;Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/&gt; &lt;Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/&gt; &lt;Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/&gt; &lt;Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/&gt; &lt;Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/&gt; &lt;Setter Property="Padding" Value="10,3,10,5"/&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="RadioButton"&gt; &lt;Grid Background="Transparent"&gt; &lt;VisualStateManager.VisualStateGroups&gt; &lt;VisualStateGroup x:Name="CheckStates"&gt; &lt;VisualState x:Name="Checked"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="Red"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="Unchecked"/&gt; &lt;VisualState x:Name="Indeterminate"/&gt; &lt;/VisualStateGroup&gt; &lt;VisualStateGroup x:Name="CommonStates"&gt; &lt;VisualState x:Name="Normal"/&gt; &lt;VisualState x:Name="MouseOver"/&gt; &lt;VisualState x:Name="Pressed"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="Gray"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;VisualState x:Name="Disabled"&gt; &lt;Storyboard&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground"&gt; &lt;DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/&gt; &lt;/ObjectAnimationUsingKeyFrames&gt; &lt;/Storyboard&gt; &lt;/VisualState&gt; &lt;/VisualStateGroup&gt; &lt;/VisualStateManager.VisualStateGroups&gt; &lt;Border x:Name="ButtonBackground" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="0" Margin="{StaticResource PhoneTouchTargetOverhang}"&gt; &lt;ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/&gt; &lt;/Border&gt; &lt;/Grid&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload