This is a migrated thread and some comments may be shown as answers.

Chanhe form TitleBar buttons color

6 Answers 112 Views
TitleBar
This is a migrated thread and some comments may be shown as answers.
miki
Top achievements
Rank 1
miki asked on 01 Jan 2015, 04:47 PM
I am try to change Minimize and Maximize color:

private void MainForm_Load(object sender, EventArgs e)
{
    FormElement.TitleBar.MinimizeButton.ForeColor = Color.White;
    FormElement.TitleBar.MaximizeButton.ForeColor = Color.White;
}

But the color is still in the default color (black).
Am i doing something wrong ?

6 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 02 Jan 2015, 01:33 PM
Hello Miki,

Thank you for writing.

The buttons in the title bar are RadImageButtonElements, and they work with images, rather than colors. To change their images, you need to edit the theme you use. Attached you can find a screen shot of the
elements you need to style. Note that you will also have to style the different states - MouseOver, Minimized, Maximized, etc.

In code, you can enable the colors for these buttons by hiding the ImavePrimitive, holding the image, showing the hidden FillPrimive and assign whatever colors you need to it. You can also use the MouseEnter and MouseLeave events to set/reset the colors:
protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
 
    InitializeComponent();
 
    this.FormElement.TitleBar.MinimizeButton.MouseEnter += MinimizeButton_MouseEnter;
    this.FormElement.TitleBar.MinimizeButton.MouseLeave += MinimizeButton_MouseLeave;
}
 
void MinimizeButton_MouseLeave(object sender, EventArgs e)
{
    this.FormElement.TitleBar.MinimizeButton.ButtonFillElement.ResetValue(FillPrimitive.BackColorProperty, ValueResetFlags.Local);
    this.FormElement.TitleBar.MinimizeButton.ButtonFillElement.ResetValue(FillPrimitive.VisibilityProperty, ValueResetFlags.Local);
    this.FormElement.TitleBar.MinimizeButton.ButtonFillElement.ResetValue(FillPrimitive.GradientStyleProperty, ValueResetFlags.Local);
 
    this.FormElement.TitleBar.MinimizeButton.ImagePrimitive.ResetValue(ImagePrimitive.VisibilityProperty, ValueResetFlags.Local);
 
}
 
void MinimizeButton_MouseEnter(object sender, EventArgs e)
{
    this.FormElement.TitleBar.MinimizeButton.ButtonFillElement.Visibility = ElementVisibility.Visible;
    this.FormElement.TitleBar.MinimizeButton.ButtonFillElement.BackColor = Color.Red;
    this.FormElement.TitleBar.MinimizeButton.ImagePrimitive.Visibility = ElementVisibility.Hidden;
    this.FormElement.TitleBar.MinimizeButton.ButtonFillElement.GradientStyle = GradientStyles.Solid;
}

I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

Regards,
Stefan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
miki
Top achievements
Rank 1
answered on 02 Jan 2015, 06:42 PM
I only want to change the color to White, your code just change the color when Mouse over and the default color remain black
0
miki
Top achievements
Rank 1
answered on 02 Jan 2015, 06:44 PM
Please see the attach file, this is the color i would like to change
0
Stefan
Telerik team
answered on 05 Jan 2015, 09:20 AM
Hello Miki,

To change the buttons colors, you need to assign an image with the desired colors. Here is a code snippet:
this.FormElement.TitleBar.MinimizeButton.Image = yourWhiteImage;
this.FormElement.TitleBar.MaximizeButton.Image = yourWhiteImage;
this.FormElement.TitleBar.CloseButton.Image = yourWhiteImage;

I hope this helps.

Regards,
Stefan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
miki
Top achievements
Rank 1
answered on 05 Jan 2015, 09:43 AM
What kind of image i need to set in order to change the button ? a simple White rectangle is OK ?
0
Stefan
Telerik team
answered on 05 Jan 2015, 12:05 PM
Whatever image you set, this is what you will see. If you set white rectangle, you will see white rectangle. If you set, red cross, you will see red cross.

I hope this helps.

Regards,
Stefan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
TitleBar
Asked by
miki
Top achievements
Rank 1
Answers by
Stefan
Telerik team
miki
Top achievements
Rank 1
Share this question
or