How do I make the Context Menu to close after a set time interval?

To automatically close the context menu after a set time interval, you can use a Timer and send an Esc keystroke after the desired time interval as shown. [C#] private void timer1_Tick(object sender, System.EventArgs e) { SendKeys.Send('{ESC}'); timer1.Stop(); } private void contextMenu1_Popup(object sender, System.EventArgs e) { //set interval to 5 seconds timer1.Interval = 5000; timer1.Start(); }

How to determine which Panel in the Windows Forms StatusBar Control is Clicked ?

[C#] private void statusBar1_PanelClick(object sender, System.Windows.Forms.StatusBarPanelClickEventArgs e) { switch (statusBar1.Panels.IndexOf(e.StatusBarPanel)) { case 0 : MessageBox.Show('You have clicked Panel One.'); break; case 1 : MessageBox.Show('You have clicked Panel Two.'); break; } } //Place the following code in the form’s constructor to register the event handler. this.statusBar1.PanelClick += new System.Windows.Forms.StatusBarPanelClickEventHandler (this.statusBar1_PanelClick);

How can I use the attached properties of Canvas to position child elements ?

This example shows how to use the attached properties of Canvas to position child elements. [XAML] <Page xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' WindowTitle='Canvas Attached Properties Sample'> <Border HorizontalAlignment='Left' VerticalAlignment='Top' BorderBrush='Black' BorderThickness='2'> <Canvas Background='LightBlue' Width='400' Height='400'> <Button Canvas.Top='50'>Canvas.Top='50'</Button> <Button Canvas.Bottom='50'>Canvas.Bottom='50'</Button> <Button Canvas.Left='50'>Canvas.Left='50'</Button> <Button Canvas.Right='50'>Canvas.Right='50'</Button> </Canvas> </Border> </Page>

How do I make a Button to trigger a Click event at specific time intervals when the mouse is down like a ScrollBar button?

This can be done with the following piece of code. [C#] public class RepeatButton : Button { private Timer timer1; public int Interval { get { return Timer.Interval; } set { Timer.Interval = value; } } private Timer Timer { get { if ( timer1 == null ) { // create and setup the timer timer1 = new Timer(); timer1.Tick += new EventHandler( OnTimer ); timer1.Enabled = false; } return timer1; } } protected override void OnMouseDown( MouseEventArgs me ) { base.OnMouseDown( me ); Timer.Enabled = true; // turn on the timer } protected override void OnMouseUp( MouseEventArgs me ) { Timer.Enabled = false; // turn off the timer base.OnMouseUp( me ); } private void OnTimer( object sender, EventArgs e ) { OnClick( EventArgs.Empty ); // fire off a click on each timer tick } }

How can I use a BulletDecorator control that uses an image as the Bullet and a non-text element as the Child ?

The following example shows how to define a BulletDecorator control that uses an ’image’ as the Bullet and a ’non-text element’ as the Child. In this example, the Bullet object centers itself next to the non-text element. [XAML] <BulletDecorator Grid.Row='3' Grid.Column='0' Margin='0,5,0,0'> <BulletDecorator.Bullet> <Image Source='images\apple.jpg'/> </BulletDecorator.Bullet> <Ellipse Height='75' Width='50' Fill='Purple' HorizontalAlignment='Left' ></Ellipse> </BulletDecorator>