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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:52:45+00:00 2026-06-12T23:52:45+00:00

Before I start, I have to say this. I have read this question .

  • 0

Before I start, I have to say this. I have read this question. And I dont see how its a duplicate of this question that I posted a few hours ago.

My original post as it is:

I am using a few buttons in WPF for displaying images from various folders. The Click mode for all the buttons is Hover. For some button, after hovering, it is routed to a function OnButtonClick. What I want to do is, ONLY after the mouse is over the button for X seconds, the processing inside the function OnButtonClick should be done.

XAML Code:

    <Button Name="Dresses" MouseEnter="onMouseEnter" MouseLeave="onMouseLeave" Content="Dresses" Grid.Row="2" Height="25" Width="85" VerticalAlignment="Center" Grid.Column="5"  FontFamily="Tahoma" FontSize="14" FontWeight="Bold" HorizontalAlignment="Center" Cursor="Hand" ClickMode="Hover">
        <Button.Background>
            <LinearGradientBrush>
                <GradientStop Color="Yellow" Offset="0" />
                <GradientStop Color="Green" Offset="1" />
            </LinearGradientBrush>
        </Button.Background>
    </Button>

C# Code:

    private void OnButtonClickDresses(object sender, RoutedEventArgs e)
    {
            //Code for delay

            //Code which should run only if mouse on button after 5 seconds

    }

PS: I am a beginner in WPF and C#. So if you can post a minimum working example I’d be actually very grateful.

  • 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-12T23:52:46+00:00Added an answer on June 12, 2026 at 11:52 pm

    Here is a sample application for you.

    using System.Windows.Threading;
    
    namespace MyWPF App
    {
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    
    public partial class MainWindow : Window
    {
    
        DateTime dt;
        DispatcherTimer t;
    
        public MainWindow()
        {
    
            InitializeComponent();
            t = new DispatcherTimer();
            t.Tick += new EventHandler(t_Tick);
    
        }
        private void button1_MouseEnter(object sender, MouseEventArgs e)
        {
            dt=DateTime.Now;
            t.Interval = new TimeSpan(0, 0, 1);
            t.IsEnabled = true;
    
    
        }
    
        void t_Tick(object sender, EventArgs e)
        {
    
            if ((DateTime.Now - dt).Seconds >= 5)
            {
                MessageBox.Show("Hello");// Here you can put your code which you want to execute after 5 seconds.
            }
    
        }
    
        private void button1_MouseLeave(object sender, MouseEventArgs e)
        {
            t.IsEnabled = false;
        }
    }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Before i start id like to say ive posted this question as more of
before I start I want to point out that I tagged this question as
Before I start with the real question, let me just say that I might
(Before I start, yes I have asked a similar question before; unfortunately due to
(before I start I should say yes, I have done all the stupidity checks,
Let's say I have a rails app with content that's read-only to the public,
Before I start I must say that I maybe biting more than I can
Ok before I start I want to say, I am totally new to this
Before I start: I'm programming for Iphone, using objective C. I have already implemented
Am using Mediainfo library in my C# project,before start invoking this dll,i just ran

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.