Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 661989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:19:43+00:00 2026-05-13T23:19:43+00:00

General context : MVVM application. I have a View called JobView. Its DataContext is

  • 0

General context : MVVM application.

I have a View called JobView. Its DataContext is a class called Job. Within Job is a property called AuthorizationNeeded.

A Border in the view has a style (from a resource dictionary) and that style has a data trigger which starts and stops a storyboard based on the bound property AuthorizationNeeded.

<Style x:Key="AuthorizationNeededBorder"
       TargetType="Border">
    <Setter Property="Background"
            Value="Yellow" />
    <Setter Property="Opacity"
            Value="0" />
    <Style.Triggers>
        <DataTrigger Binding="{Binding AuthorizationNeeded, FallbackValue=False}"
                     Value="True">
            <DataTrigger.EnterActions>
                <BeginStoryboard Name="Flash"
                                 Storyboard="{StaticResource OneSecondOpacityFlash}" />
            </DataTrigger.EnterActions>
            <DataTrigger.ExitActions>
                <RemoveStoryboard BeginStoryboardName="Flash" />
            </DataTrigger.ExitActions>
        </DataTrigger>
    </Style.Triggers>
</Style>

Everything works as expected. Changing AuthorizationNeeded’s value starts the storyboard flash when moving to true and removes (and stops) the storyboard when moving to false.

However, if I change the DataContext of JobView to a different ViewModel (a different Job) while the storyboard is running, even if the value of AuthorizationNeeded is false in the new Job, the storyboard continues to run.

The data trigger is not seeing the change of value from AuthorizationNeeded true -> false during the DataContext change.

Any ideas on how I can get to the desired behavior of AuthorizationNeed = true = storboard running to AuthorizationNeeded = false = storyboard not running under all circumstances would be greatly appreciated. (I would prefer not to manually change the value of AuthorizationNeeded at a DataContext change because in reality there are many such triggers on this view…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:19:44+00:00Added an answer on May 13, 2026 at 11:19 pm

    I would consider adding a trigger to the DataContextChanged event on the object. Something like:

    <Style.Triggers>
        <EventTrigger EventName="DataContextChanged">
            <StopStoryboard Storyboard="{StaticResource OneSecondOpacityFlash}" />
        </EventTrigger>
    </Style.Triggers>
    

    I would wonder, though, if you want to change the DataContext on an existing view object or if it would be better to create a new view bound to the new DataContext. Depending on what you’re doing, I would think that swapping out DataContexts could result in extra handles being held. Depending on what your container is, it may be easier to remove and re-create the child view/viewmodel than to swap.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What should be the general guidelines/gotchas for dividing application code (App_Code) into separate files?
A general architecture question in Sitecore 6... Let’s say we have a situation where
I am squaring each integer in a List. Here is the code. class SomeIntgs
Apples documentation states that in general Quartz2D is thread-safe . However when drawing to
When creating a designable .NET component, you are required to provide a default constructor.
Recently this question was posted about the definition of what a transaction is in
The question Is it possible to ask SSIS to cast a value and return
This is actually a two part question. First,does the HttpContext.Current correspond to the current
In C# and in Java (and possibly other languages as well), variables declared in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.