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

Theme not responding to custom property changed

2 Answers 63 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
Kevin Meyer
Top achievements
Rank 1
Kevin Meyer asked on 01 Apr 2009, 10:46 PM
I'm extending a rad element for custom behavior (specifically, I'm making a multi-select drop down where the textbox acts as a search input).  I'm trying to add a custom property, IsHighlighted to RadListBoxItem.  I have a custom XML style sheet for my control which is being loaded and works, except that it doesn't highlight as expected.

Here are the modifications I've made:
  • I've created a MultiSelectComboBoxElement that extends RadComboBoxElement.  I define a public static RadProperty IsHighlightedProperty in this class.  It's static constructor registers my theme (XML) from storage (this was based on the default combobox theme) and registers the property as follows: 
IsHighlightedProperty = RadProperty.Register("IsHighlighted"typeof(bool), typeof(RadListBoxItem), new RadElementPropertyMetadata(false, ElementPropertyOptions.AffectsDisplay)); 
  Notice, I'm trying to add the rad property to RadListBoxItem in the MultiSelectComboBoxElement static constructor.

  • My theme (XML) defines some visual settings for RadListBoxItems with selector condtions that use my new property.  Here's one example:
<XmlPropertySettingGroup> 
  <PropertySettings> 
    <XmlPropertySetting Property="Telerik.WinControls.Primitives.FillPrimitive.GradientStyle" Value="Linear" /> 
    <XmlPropertySetting Property="Telerik.WinControls.Primitives.FillPrimitive.NumberOfColors" Value="4" /> 
    <XmlPropertySetting Property="Telerik.WinControls.Primitives.FillPrimitive.GradientAngle" Value="90" /> 
    <XmlPropertySetting Property="Telerik.WinControls.Primitives.FillPrimitive.GradientPercentage" Value="0.5015975" /> 
    <XmlPropertySetting Property="Telerik.WinControls.Primitives.FillPrimitive.GradientPercentage2" Value="0.5623003" /> 
    <XmlPropertySetting Property="Telerik.WinControls.RadElement.Visibility" Value="Visible" /> 
    <XmlAnimatedPropertySetting EndValue="White" Property="Telerik.WinControls.VisualElement.BackColor" Value="" />
    <XmlAnimatedPropertySetting EndValue="255, 235, 173" Property="Telerik.WinControls.Primitives.FillPrimitive.BackColor2" Value="" />
    <XmlAnimatedPropertySetting EndValue="255, 215, 106" Property="Telerik.WinControls.Primitives.FillPrimitive.BackColor3" Value="" /> 
              <XmlAnimatedPropertySetting EndValue="255, 213, 156" Property="Telerik.WinControls.Primitives.FillPrimitive.BackColor4" Value="" /> 
  </PropertySettings> 
  <Selectors> 
    <XmlClassSelector ElementClass="ListBoxItemSelectionFill" AutoUnapply="False"
      <Condition xsi:type="XmlSimpleCondition" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        <Setting Property="Telerik.WinControls.UI.RadListBoxItem.IsHighlighted" Value="True" /> 
      </Condition> 
    </XmlClassSelector> 
  </Selectors> 
 </XmlPropertySettingGroup> 

I set the IsHighlighted value in code using item.SetValue(IsHighlightedProperty, true). This seems to work because subsequent calls to item.GetValue(IsHighlightedProperty) return true. I know telerik is using my theme as I see other visual changes and it does not throw any exceptions about not being able to find the IsHighlighted property, but the control style never changes at runtime (the item's background doesn't change).  Any help would be greatly appreciated.

2 Answers, 1 is accepted

Sort by
0
Kevin Meyer
Top achievements
Rank 1
answered on 02 Apr 2009, 06:12 PM
I've realized my issue and got this working now.  I'm using my custom IsHighlighted property in the theme to select child elements of the RadListBoxItem, but I was only setting the IsHighlighted property on RadListBoxItemI've modified my code to assign the IsHighlighted property of all child elements of the RadListBoxItem whenever the property changes on the parent.
0
Nick
Telerik team
answered on 03 Apr 2009, 03:24 PM
Hi Kevin Meyer,

I am glad you found a solution and thank you for sharing it with the community.

 
Regards,
Nick
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Themes and Visual Style Builder
Asked by
Kevin Meyer
Top achievements
Rank 1
Answers by
Kevin Meyer
Top achievements
Rank 1
Nick
Telerik team
Share this question
or