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

1 Answer 141 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!!! :-)
Tags
NavigationView PageView
Asked by
Simos Sigma
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Maria
Telerik team
Share this question
or