다음은 UserControl입니다.
<Grid x:Name="LayoutRoot">
<Border x:Name="Border1" Background="Green">
<TextBlock Text="Hello, World!"></TextBlock>
</Border>
</Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup >
<VisualState x:Name="ExampleState">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="Border1">
<DiscreteObjectKeyFrame KeyTime="0" Value="Red">
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
그리고 코드 숨김 어딘가에 :
public DialerView()
{
this.InitializeComponent();
//LayoutRoot.DataContext = this;
VisualStateManager.GoToState(this, "ExampleState", false);
}
왜 Border1이 빨간색으로 색상을 변경하지 않는지 설명해 주시겠습니까?
예, VSM은 그리드에 있어야하며 이제 모든 것이 작동합니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다