How do I put controls such as a ProgressBar into a StatusBar ?

You cannot place controls into a StatusBar control in the Designer. However, you can add any number of controls to the StatusBar programmatically through it’s ‘Controls’ property. After adding the controls, set their Visible, Location, Bounds and other properties. Here’s a sample method that could be called in a form’s constructor after the ’InitializeComponent’. [C#] private void AddStatusBarControls(StatusBar sb) { ProgressBar pb = new ProgressBar(); sb.Controls.Add(pb); pb.Visible = true; pb.Bounds = new Rectangle(sb.Width / 4, 4, sb.Width / 2, sb.Height – 8); pb.Anchor = AnchorStyles.Left | AnchorStyles.Right; }

How do I add custom drawing to a Button?

‘Subclass Button’ and adding a custom ‘Paint’ event handler lets you do this. [C#] public class CustomButton : Button { public CustomButton() { Paint += new PaintEventHandler( ButtonPaint ); } private void ButtonPaint( object sender, PaintEventArgs e ) { Pen pen = new Pen( Color.Red ); pen.Width = 8; e.Graphics.DrawLine( pen, 7, 4, 7, Height – 4 ); pen.Width = 1; e.Graphics.DrawEllipse( pen, Width – 16 , 6, 8, 8 ); } }

How do I change the location of a model in WPF ?

Each model has a particular location in the scene. In order to move the model around the scene, rotate the model or to change it’s size, it is not practical to change the vertices of a model like the 2D objects. Instead 3D models have the ‘Transform’ property with which you can move the models, change their sizes or rotate them.

How can I specify a Custom Popup Position ?

You can specify a custom pop-up location by setting the Placement property to Custom. This can be done with the following code snippets. [XAML] <Popup Name=”myCustomPopup” PlacementTarget =”{Binding ElementName=myGridLayout}” Placement=”Custom”> <TextBlock Height=”50″ Width=”150″ Background=”LightGray” TextWrapping=”Wrap”>Custom popup position demo</TextBlock> </Popup> [C#] public CustomPopupPlacement[] placementForPopup(Size popupSize, Size targetSize, Point offset) { CustomPopupPlacement customPlacement1 = new CustomPopupPlacement(new Point(-40, 90), PopupPrimaryAxis.Vertical); CustomPopupPlacement customPlacement2 = new CustomPopupPlacement(new Point(20, 30), PopupPrimaryAxis.Horizontal); CustomPopupPlacement[] customPlacements = new CustomPopupPlacement[] { customPlacement1 , customPlacement2 }; return customPlacements ; } [C#] myCustomPopup.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(placementForPopup); Reference link: https://docs.microsoft.com/en-us/dotnet/framework/wpf/controls/how-to-specify-a-custom-popup-position

How do I support drag-and-drop for a RichTextBox?

You must set the ‘AllowDrop’ property on the RichTextBox control to true and also handle both the ‘DragEnter’ and ‘DragDrop’ events. Add event handlers to the control as given below. [C#] using System.Windows.Forms; richTextBox1.DragEnter += new DragEventHandler( richTextBox1_DragEnter ); richTextBox1.DragDrop += new DragEventHandler( richTextBox1_DragDrop ); Write event handlers : { private void richTextBox1_DragEnter(object sender, DragEventArgs e) { e.Effect = e.Data.GetDataPresent(DataFormats.Text) ? DragDropEffects.Copy : DragDropEffects.None; } private void richTextBox1_DragDrop(object sender, DragEventArgs e) { // Load the file into the control string text = (string)e.Data.GetData(‘Text’); richTextBox1.LoadFile(text, RichTextBoxStreamType.RichText); } public Window1() { InitializeComponent(); } }