Storyboard Triggers only once for second condition
I have a button on which Click, TextBlock MultiDataTrigger runs but on every button click it runs only twice.
Explaination: First Default TextBlock Text is Disconnected then there are two MultiDataTriggers out of which satisfies the condition runs and then after another MultiDataTrigger on again button click but after this no Storyboard animation works.
Textblock
<TextBlock x:Name="abctxt" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" Text="Disconnected">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=sbbtn, Path=IsPressed}" Value="True" />
<Condition Binding="{Binding ElementName=abctxt, Path=Text}" Value="Connected" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource DisconnectedTextChange}"/>
</MultiDataTrigger.EnterActions>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=sbbtn, Path=IsPressed}" Value="True" />
<Condition Binding="{Binding ElementName=abctxt, Path=Text}" Value="Disconnected" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource ConnectedTextChange}"/>
</MultiDataTrigger.EnterActions>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
Button
<Button x:Name="sbbtn" />
Storyboard
<Storyboard x:Key="ConnectedTextChange" x:Name="ConnectedTextChange">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Connected"/>
</StringAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="DisconnectedTextChange" x:Name="DisconnectedTextChange">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Disconnected"/>
</StringAnimationUsingKeyFrames>
</Storyboard>
c# wpf xaml storyboard
|
show 1 more comment
I have a button on which Click, TextBlock MultiDataTrigger runs but on every button click it runs only twice.
Explaination: First Default TextBlock Text is Disconnected then there are two MultiDataTriggers out of which satisfies the condition runs and then after another MultiDataTrigger on again button click but after this no Storyboard animation works.
Textblock
<TextBlock x:Name="abctxt" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" Text="Disconnected">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=sbbtn, Path=IsPressed}" Value="True" />
<Condition Binding="{Binding ElementName=abctxt, Path=Text}" Value="Connected" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource DisconnectedTextChange}"/>
</MultiDataTrigger.EnterActions>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=sbbtn, Path=IsPressed}" Value="True" />
<Condition Binding="{Binding ElementName=abctxt, Path=Text}" Value="Disconnected" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource ConnectedTextChange}"/>
</MultiDataTrigger.EnterActions>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
Button
<Button x:Name="sbbtn" />
Storyboard
<Storyboard x:Key="ConnectedTextChange" x:Name="ConnectedTextChange">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Connected"/>
</StringAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="DisconnectedTextChange" x:Name="DisconnectedTextChange">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Disconnected"/>
</StringAnimationUsingKeyFrames>
</Storyboard>
c# wpf xaml storyboard
It seems that the text is hold as “Connected” by the ConnectedTextChange Storyboard so the other Storyboard cannot change it back to “Disconnected”.
– kennyzx
Nov 24 '18 at 4:36
@kennyzx have try this? Any suggestion, what should i do?
– Code Learner
Nov 24 '18 at 8:39
do you have to use an animation (Storyboard)? Or do you just want to change the Text in response to the button click? By default, a Storyboard holds the final value when the Storyboard is completed.
– kennyzx
Nov 24 '18 at 8:43
@kennyzx no! i have to use storyboard, actually i have a another control(Rectangle which slide through margins using storyboard) also which also have same condition as textblock but both textblock and rectangle begin storyboard only once
– Code Learner
Nov 24 '18 at 8:54
@sachinshinde try my approach does same thing correctly.
– Shubham Sahu
Nov 27 '18 at 9:27
|
show 1 more comment
I have a button on which Click, TextBlock MultiDataTrigger runs but on every button click it runs only twice.
Explaination: First Default TextBlock Text is Disconnected then there are two MultiDataTriggers out of which satisfies the condition runs and then after another MultiDataTrigger on again button click but after this no Storyboard animation works.
Textblock
<TextBlock x:Name="abctxt" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" Text="Disconnected">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=sbbtn, Path=IsPressed}" Value="True" />
<Condition Binding="{Binding ElementName=abctxt, Path=Text}" Value="Connected" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource DisconnectedTextChange}"/>
</MultiDataTrigger.EnterActions>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=sbbtn, Path=IsPressed}" Value="True" />
<Condition Binding="{Binding ElementName=abctxt, Path=Text}" Value="Disconnected" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource ConnectedTextChange}"/>
</MultiDataTrigger.EnterActions>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
Button
<Button x:Name="sbbtn" />
Storyboard
<Storyboard x:Key="ConnectedTextChange" x:Name="ConnectedTextChange">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Connected"/>
</StringAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="DisconnectedTextChange" x:Name="DisconnectedTextChange">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Disconnected"/>
</StringAnimationUsingKeyFrames>
</Storyboard>
c# wpf xaml storyboard
I have a button on which Click, TextBlock MultiDataTrigger runs but on every button click it runs only twice.
Explaination: First Default TextBlock Text is Disconnected then there are two MultiDataTriggers out of which satisfies the condition runs and then after another MultiDataTrigger on again button click but after this no Storyboard animation works.
Textblock
<TextBlock x:Name="abctxt" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2" HorizontalAlignment="Center" Text="Disconnected">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=sbbtn, Path=IsPressed}" Value="True" />
<Condition Binding="{Binding ElementName=abctxt, Path=Text}" Value="Connected" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource DisconnectedTextChange}"/>
</MultiDataTrigger.EnterActions>
</MultiDataTrigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding ElementName=sbbtn, Path=IsPressed}" Value="True" />
<Condition Binding="{Binding ElementName=abctxt, Path=Text}" Value="Disconnected" />
</MultiDataTrigger.Conditions>
<MultiDataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource ConnectedTextChange}"/>
</MultiDataTrigger.EnterActions>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
Button
<Button x:Name="sbbtn" />
Storyboard
<Storyboard x:Key="ConnectedTextChange" x:Name="ConnectedTextChange">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Connected"/>
</StringAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="DisconnectedTextChange" x:Name="DisconnectedTextChange">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Disconnected"/>
</StringAnimationUsingKeyFrames>
</Storyboard>
c# wpf xaml storyboard
c# wpf xaml storyboard
edited Nov 23 '18 at 10:13
Code Learner
asked Nov 22 '18 at 15:54
Code LearnerCode Learner
448
448
It seems that the text is hold as “Connected” by the ConnectedTextChange Storyboard so the other Storyboard cannot change it back to “Disconnected”.
– kennyzx
Nov 24 '18 at 4:36
@kennyzx have try this? Any suggestion, what should i do?
– Code Learner
Nov 24 '18 at 8:39
do you have to use an animation (Storyboard)? Or do you just want to change the Text in response to the button click? By default, a Storyboard holds the final value when the Storyboard is completed.
– kennyzx
Nov 24 '18 at 8:43
@kennyzx no! i have to use storyboard, actually i have a another control(Rectangle which slide through margins using storyboard) also which also have same condition as textblock but both textblock and rectangle begin storyboard only once
– Code Learner
Nov 24 '18 at 8:54
@sachinshinde try my approach does same thing correctly.
– Shubham Sahu
Nov 27 '18 at 9:27
|
show 1 more comment
It seems that the text is hold as “Connected” by the ConnectedTextChange Storyboard so the other Storyboard cannot change it back to “Disconnected”.
– kennyzx
Nov 24 '18 at 4:36
@kennyzx have try this? Any suggestion, what should i do?
– Code Learner
Nov 24 '18 at 8:39
do you have to use an animation (Storyboard)? Or do you just want to change the Text in response to the button click? By default, a Storyboard holds the final value when the Storyboard is completed.
– kennyzx
Nov 24 '18 at 8:43
@kennyzx no! i have to use storyboard, actually i have a another control(Rectangle which slide through margins using storyboard) also which also have same condition as textblock but both textblock and rectangle begin storyboard only once
– Code Learner
Nov 24 '18 at 8:54
@sachinshinde try my approach does same thing correctly.
– Shubham Sahu
Nov 27 '18 at 9:27
It seems that the text is hold as “Connected” by the ConnectedTextChange Storyboard so the other Storyboard cannot change it back to “Disconnected”.
– kennyzx
Nov 24 '18 at 4:36
It seems that the text is hold as “Connected” by the ConnectedTextChange Storyboard so the other Storyboard cannot change it back to “Disconnected”.
– kennyzx
Nov 24 '18 at 4:36
@kennyzx have try this? Any suggestion, what should i do?
– Code Learner
Nov 24 '18 at 8:39
@kennyzx have try this? Any suggestion, what should i do?
– Code Learner
Nov 24 '18 at 8:39
do you have to use an animation (Storyboard)? Or do you just want to change the Text in response to the button click? By default, a Storyboard holds the final value when the Storyboard is completed.
– kennyzx
Nov 24 '18 at 8:43
do you have to use an animation (Storyboard)? Or do you just want to change the Text in response to the button click? By default, a Storyboard holds the final value when the Storyboard is completed.
– kennyzx
Nov 24 '18 at 8:43
@kennyzx no! i have to use storyboard, actually i have a another control(Rectangle which slide through margins using storyboard) also which also have same condition as textblock but both textblock and rectangle begin storyboard only once
– Code Learner
Nov 24 '18 at 8:54
@kennyzx no! i have to use storyboard, actually i have a another control(Rectangle which slide through margins using storyboard) also which also have same condition as textblock but both textblock and rectangle begin storyboard only once
– Code Learner
Nov 24 '18 at 8:54
@sachinshinde try my approach does same thing correctly.
– Shubham Sahu
Nov 27 '18 at 9:27
@sachinshinde try my approach does same thing correctly.
– Shubham Sahu
Nov 27 '18 at 9:27
|
show 1 more comment
1 Answer
1
active
oldest
votes
Instead of checking textbox text or button pressed go with single condition IsChecked,
Instead of using a simple Button use ToggleButton and apply your Button style on it.
You can use it like this way:
Your TextBlock
<TextBlock x:Name="abctxt" Text="Disconnected" />
ToggleButton Instead of Button
<ToggleButton x:Name="sbbtn"> <!-- Also Apply Your Style For making your ToggleButton looks like your Button -->
<ToggleButton.Triggers>
<EventTrigger RoutedEvent="ToggleButton.Checked">
<BeginStoryboard Storyboard="{StaticResource ConnectedTextChange}" />
</EventTrigger>
<EventTrigger RoutedEvent="ToggleButton.Unchecked">
<BeginStoryboard Storyboard="{StaticResource DisconnectedTextChange}" />
</EventTrigger>
</ToggleButton.Triggers>
Your Storyboard
<!-- Here i set TargetName also -->
<Storyboard x:Key="ConnectedTextChange" x:Name="ConnectedTextChange" Storyboard.TargetName="abctxt">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Connected"/>
</StringAnimationUsingKeyFrames>
<Storyboard x:Key="DisconnectedTextChange" x:Name="DisconnectedTextChange" Storyboard.TargetName="abctxt">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Disconnected"/>
</StringAnimationUsingKeyFrames>
</Storyboard>
1
Thanks' its works as intended, also thanks for suggestion of using toggle button.
– Code Learner
Nov 27 '18 at 9:57
@sachinshinde Glad it worked
– Shubham Sahu
Nov 27 '18 at 9:58
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434537%2fstoryboard-triggers-only-once-for-second-condition%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Instead of checking textbox text or button pressed go with single condition IsChecked,
Instead of using a simple Button use ToggleButton and apply your Button style on it.
You can use it like this way:
Your TextBlock
<TextBlock x:Name="abctxt" Text="Disconnected" />
ToggleButton Instead of Button
<ToggleButton x:Name="sbbtn"> <!-- Also Apply Your Style For making your ToggleButton looks like your Button -->
<ToggleButton.Triggers>
<EventTrigger RoutedEvent="ToggleButton.Checked">
<BeginStoryboard Storyboard="{StaticResource ConnectedTextChange}" />
</EventTrigger>
<EventTrigger RoutedEvent="ToggleButton.Unchecked">
<BeginStoryboard Storyboard="{StaticResource DisconnectedTextChange}" />
</EventTrigger>
</ToggleButton.Triggers>
Your Storyboard
<!-- Here i set TargetName also -->
<Storyboard x:Key="ConnectedTextChange" x:Name="ConnectedTextChange" Storyboard.TargetName="abctxt">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Connected"/>
</StringAnimationUsingKeyFrames>
<Storyboard x:Key="DisconnectedTextChange" x:Name="DisconnectedTextChange" Storyboard.TargetName="abctxt">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Disconnected"/>
</StringAnimationUsingKeyFrames>
</Storyboard>
1
Thanks' its works as intended, also thanks for suggestion of using toggle button.
– Code Learner
Nov 27 '18 at 9:57
@sachinshinde Glad it worked
– Shubham Sahu
Nov 27 '18 at 9:58
add a comment |
Instead of checking textbox text or button pressed go with single condition IsChecked,
Instead of using a simple Button use ToggleButton and apply your Button style on it.
You can use it like this way:
Your TextBlock
<TextBlock x:Name="abctxt" Text="Disconnected" />
ToggleButton Instead of Button
<ToggleButton x:Name="sbbtn"> <!-- Also Apply Your Style For making your ToggleButton looks like your Button -->
<ToggleButton.Triggers>
<EventTrigger RoutedEvent="ToggleButton.Checked">
<BeginStoryboard Storyboard="{StaticResource ConnectedTextChange}" />
</EventTrigger>
<EventTrigger RoutedEvent="ToggleButton.Unchecked">
<BeginStoryboard Storyboard="{StaticResource DisconnectedTextChange}" />
</EventTrigger>
</ToggleButton.Triggers>
Your Storyboard
<!-- Here i set TargetName also -->
<Storyboard x:Key="ConnectedTextChange" x:Name="ConnectedTextChange" Storyboard.TargetName="abctxt">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Connected"/>
</StringAnimationUsingKeyFrames>
<Storyboard x:Key="DisconnectedTextChange" x:Name="DisconnectedTextChange" Storyboard.TargetName="abctxt">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Disconnected"/>
</StringAnimationUsingKeyFrames>
</Storyboard>
1
Thanks' its works as intended, also thanks for suggestion of using toggle button.
– Code Learner
Nov 27 '18 at 9:57
@sachinshinde Glad it worked
– Shubham Sahu
Nov 27 '18 at 9:58
add a comment |
Instead of checking textbox text or button pressed go with single condition IsChecked,
Instead of using a simple Button use ToggleButton and apply your Button style on it.
You can use it like this way:
Your TextBlock
<TextBlock x:Name="abctxt" Text="Disconnected" />
ToggleButton Instead of Button
<ToggleButton x:Name="sbbtn"> <!-- Also Apply Your Style For making your ToggleButton looks like your Button -->
<ToggleButton.Triggers>
<EventTrigger RoutedEvent="ToggleButton.Checked">
<BeginStoryboard Storyboard="{StaticResource ConnectedTextChange}" />
</EventTrigger>
<EventTrigger RoutedEvent="ToggleButton.Unchecked">
<BeginStoryboard Storyboard="{StaticResource DisconnectedTextChange}" />
</EventTrigger>
</ToggleButton.Triggers>
Your Storyboard
<!-- Here i set TargetName also -->
<Storyboard x:Key="ConnectedTextChange" x:Name="ConnectedTextChange" Storyboard.TargetName="abctxt">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Connected"/>
</StringAnimationUsingKeyFrames>
<Storyboard x:Key="DisconnectedTextChange" x:Name="DisconnectedTextChange" Storyboard.TargetName="abctxt">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Disconnected"/>
</StringAnimationUsingKeyFrames>
</Storyboard>
Instead of checking textbox text or button pressed go with single condition IsChecked,
Instead of using a simple Button use ToggleButton and apply your Button style on it.
You can use it like this way:
Your TextBlock
<TextBlock x:Name="abctxt" Text="Disconnected" />
ToggleButton Instead of Button
<ToggleButton x:Name="sbbtn"> <!-- Also Apply Your Style For making your ToggleButton looks like your Button -->
<ToggleButton.Triggers>
<EventTrigger RoutedEvent="ToggleButton.Checked">
<BeginStoryboard Storyboard="{StaticResource ConnectedTextChange}" />
</EventTrigger>
<EventTrigger RoutedEvent="ToggleButton.Unchecked">
<BeginStoryboard Storyboard="{StaticResource DisconnectedTextChange}" />
</EventTrigger>
</ToggleButton.Triggers>
Your Storyboard
<!-- Here i set TargetName also -->
<Storyboard x:Key="ConnectedTextChange" x:Name="ConnectedTextChange" Storyboard.TargetName="abctxt">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Connected"/>
</StringAnimationUsingKeyFrames>
<Storyboard x:Key="DisconnectedTextChange" x:Name="DisconnectedTextChange" Storyboard.TargetName="abctxt">
<StringAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.Text)" AccelerationRatio="1">
<DiscreteStringKeyFrame KeyTime="0:0:0.8" Value="Disconnected"/>
</StringAnimationUsingKeyFrames>
</Storyboard>
answered Nov 27 '18 at 9:23
Shubham SahuShubham Sahu
1,2071928
1,2071928
1
Thanks' its works as intended, also thanks for suggestion of using toggle button.
– Code Learner
Nov 27 '18 at 9:57
@sachinshinde Glad it worked
– Shubham Sahu
Nov 27 '18 at 9:58
add a comment |
1
Thanks' its works as intended, also thanks for suggestion of using toggle button.
– Code Learner
Nov 27 '18 at 9:57
@sachinshinde Glad it worked
– Shubham Sahu
Nov 27 '18 at 9:58
1
1
Thanks' its works as intended, also thanks for suggestion of using toggle button.
– Code Learner
Nov 27 '18 at 9:57
Thanks' its works as intended, also thanks for suggestion of using toggle button.
– Code Learner
Nov 27 '18 at 9:57
@sachinshinde Glad it worked
– Shubham Sahu
Nov 27 '18 at 9:58
@sachinshinde Glad it worked
– Shubham Sahu
Nov 27 '18 at 9:58
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434537%2fstoryboard-triggers-only-once-for-second-condition%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It seems that the text is hold as “Connected” by the ConnectedTextChange Storyboard so the other Storyboard cannot change it back to “Disconnected”.
– kennyzx
Nov 24 '18 at 4:36
@kennyzx have try this? Any suggestion, what should i do?
– Code Learner
Nov 24 '18 at 8:39
do you have to use an animation (Storyboard)? Or do you just want to change the Text in response to the button click? By default, a Storyboard holds the final value when the Storyboard is completed.
– kennyzx
Nov 24 '18 at 8:43
@kennyzx no! i have to use storyboard, actually i have a another control(Rectangle which slide through margins using storyboard) also which also have same condition as textblock but both textblock and rectangle begin storyboard only once
– Code Learner
Nov 24 '18 at 8:54
@sachinshinde try my approach does same thing correctly.
– Shubham Sahu
Nov 27 '18 at 9:27