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

  • Home
  • SEARCH
  • 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 9286127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:20:22+00:00 2026-06-18T19:20:22+00:00

I have a DockPanel and a Button inside it. I want to animate (for

  • 0

I have a DockPanel and a Button inside it. I want to animate (for example, fade in/out) the button by event (for example, mouse hovering) in the dock panel.

EDIT

Well, I found the solution only for nontemplated/nonstyled case (see below). How to bring it to reusable way?

<DockPanel>
  <Button> 
    Name="aaa"
  </Button>

  <DockPanel.Triggers>
    <EventTrigger RoutedEvent="DockPanel.MouseEnter">
      <BeginStoryboard>
        <Storyboard>
          <DoubleAnimation 
            Duration="0:0:0.100" 
            To="1" 
            Storyboard.TargetName="aaa"
            Storyboard.TargetProperty="Opacity"/>
        </Storyboard>
      </BeginStoryboard>
    </EventTrigger>
    <EventTrigger RoutedEvent="DockPanel.MouseLeave">
      <BeginStoryboard>
        <Storyboard>
          <DoubleAnimation 
            Duration="0:0:0.100" 
            To="0" 
            Storyboard.TargetName="aaa"
            Storyboard.TargetProperty="Opacity"/>
        </Storyboard>
      </BeginStoryboard>
    </EventTrigger>    
  </DockPanel.Triggers>

</DockPanel>
  • 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-06-18T19:20:23+00:00Added an answer on June 18, 2026 at 7:20 pm

    Hmm, the only idea I have is to wrap the Controls you want to show in a ContentControl. Then you may only need to create a template for the ContentControl.

    EDIT

    ContentPresenter => ContentControl

    EDIT2

    According to the edit of the TO:

    If you would like to take an approach with events, which is a proper but IMHO less elegant approach, you would have to implement these methods in the code behind of your view. e.g.

    private void OnMouseOver(object sender, MouseEventArgs e)
    {
      var control = sender as Control; // perhaps you could cast to another base class
      if (control == null)
        return;
      // implement the behavior you like
      // ...
    }
    

    The biggest problem, and IMHO the reason why is less elegant, you have to add and remove the method to each Control which is added to the DockPanel in code behind.

    If you’re not familiar with templating it may be the better solution for you.

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

Sidebar

Related Questions

I have the following: <DockPanel Height=25 HorizontalAlignment=Stretch> <Button Content=Add x:Name=bAdd DockPanel.Dock=Left /> <Button Content=Remove
A have listbox <ListBox> <ListBox.ItemTemplate> <DataTemplate> <DockPanel> <Button Content={Binding name_trainer} Tag={Binding idPersonTrainer} DockPanel.Dock=Top HorizontalAlignment=Center>
I have a dock panel, with one label in the middle and another button
I have defined following in a ResourceDictionary: <DockPanel x:Key=errorDisplay LastChildFill=False> <Border Background=Red DockPanel.Dock=Top> <TextBlock
I have a relatively simple case where I want to repurpose a Start button
I have the following code: <DockPanel> <StackPanel DockPanel.Dock=Top Orientation=Horizontal> <RadioButton Content=_Programs IsChecked={Binding Path=ProgramBanksSelected} IsEnabled={Binding
I have a TabControl . While clicking a button I want to add a
I have a dockpanel with two buttons inside <Window x:Class=PracticeWPF.MainWindow xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=MainWindow Height=350
I have a DockPanel with two Grids (DockPanel.Dock=Right/Left). In the left i have a
On mouse is up button should show the background border I have created a

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.