Loading...
Loading...
How to create and configure Syncfusion XPTaskBar controls in Windows Forms applications. Use this skill whenever the user needs to implement expandable task panels, create Windows XP-style task menus, build collapsible navigation panels, configure multi-box task bars, or customize task bar behavior with animations and events. Covers basic setup, box/item management, layout modes, events, customization, and spacing configuration.
npx skill4agent add syncfusion/winforms-ui-components-skills syncfusion-winforms-xptaskbarusing Syncfusion.Windows.Forms.Tools;
// Create XPTaskBar control
XPTaskBar xpTaskBar1 = new XPTaskBar();
xpTaskBar1.Dock = DockStyle.Fill;
this.Controls.Add(xpTaskBar1);
// Create first task box
XPTaskBarBox box1 = new XPTaskBarBox();
box1.Text = "File Operations";
xpTaskBar1.Controls.Add(box1);
// Add items to the box
box1.Items.AddRange(new XPTaskBarItem[] {
new XPTaskBarItem("New Document", System.Drawing.Color.Empty, -1, "NewDoc"),
new XPTaskBarItem("Open File", System.Drawing.Color.Empty, -1, "OpenFile"),
new XPTaskBarItem("Save", System.Drawing.Color.Empty, -1, "Save")
});
// Handle item clicks
box1.ItemClick += (sender, e) => {
switch (e.XPTaskBarItem.Tag as string) {
case "NewDoc":
// Handle new document
break;
case "OpenFile":
// Handle file open
break;
}
};
// Create second task box
XPTaskBarBox box2 = new XPTaskBarBox();
box2.Text = "Editing Tools";
xpTaskBar1.Controls.Add(box2);
box2.Items.AddRange(new XPTaskBarItem[] {
new XPTaskBarItem("Cut", System.Drawing.Color.Empty, -1, "Cut"),
new XPTaskBarItem("Copy", System.Drawing.Color.Empty, -1, "Copy"),
new XPTaskBarItem("Paste", System.Drawing.Color.Empty, -1, "Paste")
});var taskBar = new XPTaskBar { VerticalLayout = true };
// Create boxes for different task categories
foreach (var category in new[] { "File", "Edit", "View", "Help" }) {
var box = new XPTaskBarBox { Text = category };
taskBar.Controls.Add(box);
// Add items to box
}box.ItemClick += (sender, e) => {
var command = e.XPTaskBarItem.Tag as string;
ExecuteCommand(command);
};xpTaskBar1.AutoPersistStates = true;box.AnimationDelay = 50; // Milliseconds between frames
box.AnimationPositionsCount = 15; // Number of animation steps
box.UseAdditionalAnimation = true; // Animate when adding/removing items| Property | Type | Purpose |
|---|---|---|
| bool | Set true for vertical mode (default), false for horizontal |
| int | Column width in horizontal layout mode |
| int | Interior horizontal spacing |
| int | Interior vertical spacing |
| bool | Enable automatic scrollbars when needed |
| bool | Persist expanded/collapsed state between sessions |
| bool | Enable drag-and-drop support |
| Size | Minimum control dimensions |
| Property | Type | Purpose |
|---|---|---|
| string | Box header display text |
| bool | Set true to collapse, false to expand |
| bool | Show/hide collapse button |
| bool | Allow button to toggle state |
| Color | Header background color |
| Color | Header text color |
| Font | Header text font |
| StringAlignment | Header text alignment |
| int | Delay in ms between animation frames |
| int | Number of animation steps |
| int | Height reserved for child controls |
| bool | Enable tooltips for items |
| int | Horizontal header padding |
| int | Vertical header padding |
| Property | Type | Purpose |
|---|---|---|
| string | Item display text |
| int | Index in parent box's ImageList |
| string | Tooltip text on hover |
| object | Custom data for event routing |