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

Changing the color on the selected RadPanelBarGroupElement.

2 Answers 98 Views
Panelbar (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
daveo
Top achievements
Rank 1
daveo asked on 07 Jun 2007, 05:02 PM
Hi,
I'm trying to do something which seems trivial, but I'm having the hardest time.  I have a RabPanelBar in list mode which I programmatically add RadPanelBarGroupElements to (note I have also tried to add via the designer with the same results), when on element is selected I want the header to change color and stay.

I have used the VSB to create a new theme which sets the FillPrimitive of ElementWithCaptionLayout of RadPanelBarGroupdElement.  THe theme uses different combinations of conditions (IsMouseOver and Selected) to set the color.  The problem is, it seems this part of the theme is not honored.  I can change other things in the theme and it works.

Any info or direction is much appreciated.

Thanks,
daveo

2 Answers, 1 is accepted

Sort by
0
Boyko Markov
Telerik team
answered on 11 Jun 2007, 10:04 AM
Hello daveo,

I could suggest you the following solution:
 
  1. Handle the GroupExpandedChanged event of each RadPanelBarGroupElement, e.g.

        foreach(RadPanelBarGroupElement group in this.radPanelBar1.Items )  
        {  
            group.GroupExpandedChanged += new EventHandler(group_GroupExpandedChanged);  
        }     
     
     
     
  2. Change the color of the expanded group:
     
    private RadPanelBarGroupElement lastSelectedGroup;  
             
            private void group_GroupExpandedChanged(object sender, EventArgs e)  
            {  
                if (this.lastSelectedGroup != null)  
                {  
                    FillPrimitive lastgroupFill = this.lastSelectedGroup.Children[2].Children[0] as FillPrimitive;  
     
                    lastgroupFill.ResetValue(FillPrimitive.BackColorProperty);  
                    lastgroupFill.ResetValue(FillPrimitive.BackColor2Property);  
                    lastgroupFill.ResetValue(FillPrimitive.BackColor3Property);  
                    lastgroupFill.ResetValue(FillPrimitive.BackColor4Property);  
                }  
     
     
                // resets the theme  
                string theme = this.radPanelBar1.ThemeName;  
                this.radPanelBar1.ThemeName = "no theme";  
                this.radPanelBar1.ThemeName = theme;  
     
                RadPanelBarGroupElement group = sender as RadPanelBarGroupElement;  
     
                if (group == null)  
                    return;  
     
                this.lastSelectedGroup = group;  
     
                FillPrimitive groupFill = group.Children[2].Children[0] as FillPrimitive;  
     
                // changes the backColor properties of the expanded group  
                if (!group.Expanded)  
                {        
                    groupFill.BackColor = Color.Black;  
                    groupFill.BackColor2 = Color.Black;  
                    groupFill.BackColor3 = Color.Black;  
                    groupFill.BackColor4 = Color.Black;  
                  
                }  
            }  
     
     
     

     

I hope this helps. If I could be of further assistance to you please write back.


Best wishes,

Ray

the Telerik team


Instantly find answers to your questions at the new Telerik Support Center
0
daveo
Top achievements
Rank 1
answered on 11 Jun 2007, 01:10 PM
Thanks,
I had to change a few minor things to get the exact behavior I wanted.  This was extremly helpfull, especially considering I wanted to control this programmatically instead of using a theme.

Thanks again,
daveo
Tags
Panelbar (obsolete as of Q2 2010)
Asked by
daveo
Top achievements
Rank 1
Answers by
Boyko Markov
Telerik team
daveo
Top achievements
Rank 1
Share this question
or