Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I have to create and display a digital clock in my WPF project over the MDI form's title bar.
Clock should be of same width as of Title bar & should be sticked with it i.e. resized accordingly with form resizing.

Regards,
honeyashu
Posted
Updated 15-Dec-14 20:01pm
v2
Comments
Maciej Los 16-Dec-14 2:03am    
What have you done? Where are you stuck?
What's the issue?
honeyashu 16-Dec-14 2:22am    
I haven't yet done anything. I am a Winform developer and completely novice user to WPF.
Just created a MDI UI with menus & controls and have to display a digital clock on the title bar.
Sergey Alexandrovich Kryukov 16-Dec-14 2:51am    
) 1There are no forms in WPF, 2) and no MDI; 3) and MDI is extremely poor design which Microsoft is trying to phase out...
—SA
honeyashu 16-Dec-14 2:54am    
Yes I know that & I just used this word to explain that I want to display the clock over MainForm
Sergey Alexandrovich Kryukov 16-Dec-14 3:02am    
It's much better not to use wrong terminology. Even if you understand things correctly, wrong terminology use makes it not apparent... In my comment to Solution 1, I advised not to solve this problem, especially for WPF, especially at your level of expertize; it would require disproportional effort for the sake of questionable "quality" of this feature. This is pretty difficult because it required non-client area rendering, which lies well outside of WPF, would require low-level Windows programming...
—SA

1 solution

Create a separate window for the clock.
You can put all the logic in there as well.
use these settings:
WindowStyle="None" ShowInTaskbar="False"

Initialize the clock window in your mainWindow.

Now respond to your mainWindow_SizeChanged and set the position and width of the clock window.

Don't forget to close the clockWindow on MainWindow.Close.

And set the WindowClock.Owner to the MainWindow.

Feel free to ask a question if this is not clear to you.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900