Chanhe form TitleBar buttons color

7 posts, 0 answers
  1. miki
    miki avatar
    37 posts
    Member since:
    Dec 2014

    Posted 01 Jan 2015 Link to this post

    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 ?
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 02 Jan 2015 Link to this post

    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.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. miki
    miki avatar
    37 posts
    Member since:
    Dec 2014

    Posted 02 Jan 2015 in reply to Stefan Link to this post

    I only want to change the color to White, your code just change the color when Mouse over and the default color remain black
  5. miki
    miki avatar
    37 posts
    Member since:
    Dec 2014

    Posted 02 Jan 2015 Link to this post

    Please see the attach file, this is the color i would like to change
  6. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 05 Jan 2015 Link to this post

    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.

     
  7. miki
    miki avatar
    37 posts
    Member since:
    Dec 2014

    Posted 05 Jan 2015 in reply to Stefan Link to this post

    What kind of image i need to set in order to change the button ? a simple White rectangle is OK ?
  8. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 05 Jan 2015 Link to this post

    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.

     
Back to Top
UI for WinForms is Visual Studio 2017 Ready