Category / Section
How to customize the backcolor of selected item in WinForms XPTaskBar?
1 min read
Customize the backcolor of selected item
SelectedItem backcolor can be customized while applying Office2007 or Office2010 theme to XPTaskBar. It can be achieved by setting the XPTaskBarBoxActiveHighlightedItemColor property from Office2007 or Office2010ColorTable using reflection. The following code demonstrates the same.
C#
//Office2007 Visual Style this.xpTaskBar1.Style = Syncfusion.Windows.Forms.Tools.XPTaskBarStyle.Office2007; var ColorTable = xpTaskBar1.GetType().GetProperty("Office2007ColorTable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); dynamic colortable = ColorTable.GetValue(xpTaskBar1, null); Office2007Colors Office2007ColorTable = colortable; //Selected XPTaskBarItem BackColor Office2007ColorTable.XPTaskBarBoxActiveHighlightedItemColor = Color.LightPink; //Office2010 VisualStyle this.xpTaskBar1.Style = Syncfusion.Windows.Forms.Tools.XPTaskBarStyle.Office2010; var ColorTable = xpTaskBar1.GetType().GetProperty("Office2010ColorTable", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); dynamic colortable = ColorTable.GetValue(xpTaskBar1, null); Office2010Colors Office2010ColorTable = colortable; //Selected XPTaskBarItem BackColor Office2010ColorTable.XPTaskBarBoxActiveHighlightedItemColor = Color.LightPink;
VB
'Office2007 Visual Style Me.xpTaskBar1.Style = Syncfusion.Windows.Forms.Tools.XPTaskBarStyle.Office2007 Dim ColorTable = xpTaskBar1.GetType().GetProperty("Office2007ColorTable", System.Reflection.BindingFlags.NonPublic Or System.Reflection.BindingFlags.Instance) Dim colortable_Renamed As Object = ColorTable.GetValue(xpTaskBar1, Nothing) Dim Office2007ColorTable As Office2007Colors = colortable_Renamed 'Selected XPTaskBarItem BackColor Office2007ColorTable.XPTaskBarBoxActiveHighlightedItemColor = Color. LightPink 'Office2010 VisualStyle Me.xpTaskBar1.Style = Syncfusion.Windows.Forms.Tools.XPTaskBarStyle.Office2010 Dim ColorTable = xpTaskBar1.GetType().GetProperty("Office2010ColorTable", System.Reflection.BindingFlags.NonPublic Or System.Reflection.BindingFlags.Instance) Dim colortable_Renamed As Object = ColorTable.GetValue(xpTaskBar1, Nothing) Dim Office2010ColorTable As Office2010Colors = colortable_Renamed 'Selected XPTaskBarItem BackColor Office2010ColorTable.XPTaskBarBoxActiveHighlightedItemColor = Color.LightPink
Screenshot
Figure 1: Selected item background color customized in Office2007VisualStyle XPTaskBar.
Figure 2: Selected item background color customized in Office2010VisualStyle XPTaskBar.
Samples:
C#: XPTaskBarExample
VB: XPTaskBarExample
Reference link: https://help.syncfusion.com/windowsforms/xptaskbar/visual-style