Hello,
Welcome to Microsoft Q&A!
I checked your sample, and I could see the behavior you mentioned. After debugging, I found that you are trying to go to a blank VisualState
to recover the style of your StepBarItem
like the document mentioned here- Default state, right?
The reason that why you failed is that you didn't put the blank VisualState
and other VisualState
in the same VisualStateGroup
.
This is the same reason for the sample2 as well. You need to put the blank VisualState
together with other VisualState
in the same VisualStateGroup
. But I noticed that your Sample2 will go to UnderWayInfo
state first after initialization, so the item is blue. When you go to the blank VisualState
, the item should be black as its the real default state.
You could modify the StepBarItem
style a little bit like the following so the sample1 should work correctly. And for Sample2, just do the same in your Test style.
<ControlTemplate TargetType="local:StepBarItem">
<StackPanel Spacing="5">
<VisualStateManager.VisualStateGroups>
<!--<VisualStateGroup>
</VisualStateGroup>-->
<VisualStateGroup>
<VisualState x:Name="WaitingInfo">
</VisualState>
<VisualState x:Name="UnderWayInfo">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Border"
Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0"
Value="Blue" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Number"
Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0"
Value="Blue" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Content"
Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0"
Value="Blue" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
Besides, please keep one question in one thread. Feel free to open a new question for the space question. Our engineer will help you in the new thread.
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.