How can I change the "BackColor" of selected "RadPageViewNavigationViewItem" programmatically?

1 Answer 209 Views
NavigationView PageView
Simos Sigma
Top achievements
Rank 2
Iron
Iron
Iron
Simos Sigma asked on 13 Sep 2022, 10:50 AM
Hello community!!!

I searched for this here but I didn't find something that could help me. I am trying to change the "BackColor" of selected "RadPageViewNavigationViewItem". For example the green one with the text "Subscriptions". Let's say I would like to make it red. How can I do that programmatically?



Thank you for your precious time!!!

1 Answer, 1 is accepted

Sort by
1
Accepted
Maria
Telerik team
answered on 13 Sep 2022, 02:53 PM

Hello Simos,

Thank you for the screenshot!

To change the BackColor of the selected RadPageViewNavigationViewItem you can subscribe to the SelectedPageChanging event of the RadPageView which occurs when the currently selected page is about to change. Inside the event handler, you can set the BackColor of the e.Page.Item and reset the unselected item using ResetValue() method.

public RadForm1()
{
    InitializeComponent();

    this.radNavigationView1.NavigationViewElement.SelectedItem.BackColor = Color.Red;
    this.radNavigationView1.SelectedPageChanging += RadNavigationView1_SelectedPageChanging;
}
private void RadNavigationView1_SelectedPageChanging(object sender, RadPageViewCancelEventArgs e)
{
    e.Page.Item.BackColor = Color.Red;
    radNavigationView1.NavigationViewElement.SelectedItem.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
}

Give it a try and let me know if this works for you.

Regards,
Maria
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Simos Sigma
Top achievements
Rank 2
Iron
Iron
Iron
commented on 14 Sep 2022, 08:25 AM

Hello Maria,

It worked!!! But I had to change...
this.radNavigationView1.NavigationViewElement.SelectedItem.BackColor = Color.Red;
To...
this.radNavigationView1.ViewElement.SelectedItem.BackColor = Color.Red;
Thank you for your time!!! :-)
Clint
Top achievements
Rank 1
Iron
Iron
Iron
commented on 02 Jan 2025, 09:23 PM

Any way to control the highlighting here when you are mousing over items?
Nadya | Tech Support Engineer
Telerik team
commented on 03 Jan 2025, 10:09 AM

Hello Clint,

The highlight color that appears when mouse is over the page items can be customized in the theme directly bu using the VIsual Style Builder tool. This tool allows to customize appearance for certain element states in the desired manner for you. Afterwards, when the customized theme is applied, the colors come automatically from the theme.

More useful information and guidance you can find in the following forum thread: Change Hamburger Button Color and Mouse Hover Color on Hierarchy Navigation RadPageView in UI for WinForms | Telerik Forums

I hope this information is useful. Let me know if you have other questions.

Tags
NavigationView PageView
Asked by
Simos Sigma
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Maria
Telerik team
Share this question
or