Condividi tramite


VisualState.Storyboard Proprietà

Definizione

Ottiene o imposta un oggetto Storyboard che definisce l'aspetto del controllo quando si trova nello stato rappresentato da VisualState.

public:
 property System::Windows::Media::Animation::Storyboard ^ Storyboard { System::Windows::Media::Animation::Storyboard ^ get(); void set(System::Windows::Media::Animation::Storyboard ^ value); };
public System.Windows.Media.Animation.Storyboard Storyboard { get; set; }
member this.Storyboard : System.Windows.Media.Animation.Storyboard with get, set
Public Property Storyboard As Storyboard

Valore della proprietà

Storyboard che definisce l'aspetto del controllo quando si trova nello stato rappresentato da VisualState. Il valore predefinito è null.

Esempio

Nell'esempio seguente viene creato un oggetto semplice ControlTemplate per un Button oggetto contenente un oggetto Grid. Il VisualState metodo chiamato MouseOver ha uno Storyboard che modifica il colore dell'oggetto Grid da verde a rosso quando l'utente posiziona il mouse su Button. Il VisualState chiamato Normal viene incluso in modo che quando l'utente sposta il mouse fuori dal pulsante, restituisce verde Grid .

<ControlTemplate TargetType="Button">
  <Grid >
    <VisualStateManager.VisualStateGroups>
      <VisualStateGroup x:Name="CommonStates">

        <VisualStateGroup.Transitions>

          <!--Take one half second to trasition to the MouseOver state.-->
          <VisualTransition To="MouseOver" 
            GeneratedDuration="0:0:0.5"/>
        </VisualStateGroup.Transitions>

        <VisualState x:Name="Normal" />

        <!--Change the SolidColorBrush, ButtonBrush, to red when the
            mouse is over the button.-->
        <VisualState x:Name="MouseOver">
          <Storyboard>
            <ColorAnimation Storyboard.TargetName="ButtonBrush" 
              Storyboard.TargetProperty="Color" To="Red" />
          </Storyboard>
        </VisualState>
      </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <Grid.Background>
      <SolidColorBrush x:Name="ButtonBrush" Color="Green"/>
    </Grid.Background>
  </Grid>
</ControlTemplate>

Commenti

Quando il controllo entra nello stato specificato dalla VisualState.Name proprietà , inizia Storyboard . Quando il controllo esce dallo stato, l'oggetto Storyboard si arresta.

Si applica a