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 7701713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:03:37+00:00 2026-05-31T23:03:37+00:00

i am using the MVVM design pattern and do not want much code in

  • 0

i am using the MVVM design pattern and do not want much code in my code behind. coding in XAML and C#.

when a user saves a new record i would like “record saved” to appear in a text Block then fade away.

this is the sort of thing i would like to work:

<TextBlock Name="WorkflowCreated" Text="Record saved">
  <TextBlock.Triggers>
    <DataTrigger Binding="{Binding Path=NewWorkflowCreated}">
       <DataTrigger.EnterActions>
        <BeginStoryboard>
            <Storyboard>
                <DoubleAnimation
                 Storyboard.TargetName="WorkflowCreated" 
                 Storyboard.TargetProperty="(TextBlock.Opacity)"
                 From="1.0" To="0.0" Duration="0:0:3"/>
            </Storyboard>
        </BeginStoryboard>
     </DataTrigger.EnterActions>
  </DataTrigger>
</TextBlock.Triggers>

so when NewWorkflowCreated is changed in the viewmodel it would trigger the animation, unfortunately this does not work. i have also tried this:

<TextBlock Name="Message" Text="This is a test.">
 <TextBlock.Triggers>
  <EventTrigger RoutedEvent="TextBlock.Loaded">
   <BeginStoryboard>
    <Storyboard>
      <DoubleAnimation
        Storyboard.TargetName="Message" 
        Storyboard.TargetProperty="(TextBlock.Opacity)"
        From="1.0" To="0.0" Duration="0:0:3"/>
    </Storyboard>
   </BeginStoryboard>
  </EventTrigger>
 </TextBlock.Triggers>
</TextBlock>

any help would be much appreciated. Maybe there is away that requires code in the View model?

  • 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-31T23:03:38+00:00Added an answer on May 31, 2026 at 11:03 pm

    You’re using a DataTrigger which needs to be in a style.

    <Window.DataContext>
        <WpfApplication2:TestViewModel/>
    </Window.DataContext>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.Resources>
            <Style x:Key="textBoxStyle" TargetType="{x:Type TextBlock}">
                <Style.Triggers>
                    <DataTrigger Binding="{Binding Path=NewWorkflowCreated}" Value="True">
                        <DataTrigger.EnterActions>
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation
                                        Storyboard.TargetProperty="(TextBlock.Opacity)"
                                        From="1.0" To="0.0" Duration="0:0:3"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </DataTrigger.EnterActions>
                    </DataTrigger>
                </Style.Triggers>
            </Style>
        </Grid.Resources>
        <TextBlock Name="WorkflowCreated" Style="{StaticResource textBoxStyle}" Text="Record saved" />
        <Button Content="press me" Grid.Row="1" Click="Button_Click_1"/>
    </Grid>
    
    public class TestViewModel : INotifyPropertyChanged
    {
        private bool _newWorkflowCreated;
        public bool NewWorkflowCreated
        {
            get { return _newWorkflowCreated; }
            set { 
                _newWorkflowCreated = value;
                PropertyChanged(this, new PropertyChangedEventArgs("NewWorkflowCreated"));
            }
        }
    
    
        #region Implementation of INotifyPropertyChanged
    
        public event PropertyChangedEventHandler PropertyChanged;
    
        #endregion
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pretty new to WPF and using the MVVM design pattern. To help learn
I'm creating a WPF app using the MVVM design pattern, and I'm trying to
I'm creating a WPF application using the MVVM design pattern that consists of a
I'm trying to create an silverlight application using the MVVM design pattern. It's a
I'm using C# WPF following the MVVM design pattern. Currently my View has a
I have an application which I am trying to design using the MVVM pattern.
I'm creating a WPF application using the MVVM design pattern, and I'm trying to
I'm creating a WPF TimeCard app using the MVVM design pattern, and I'm trying
I am trying to implement my first WPF application using an MVVM design pattern.
I'm using MVVM in my WPF project. Now I want to display a subwindow

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.