Theme not responding to custom property changed

3 posts, 0 answers
  1. Kevin Meyer
    Kevin Meyer avatar
    36 posts
    Member since:
    Dec 2007

    Posted 01 Apr 2009 Link to this post

    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:
        <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="" /> 
        <XmlClassSelector ElementClass="ListBoxItemSelectionFill" AutoUnapply="False"
          <Condition xsi:type="XmlSimpleCondition" xmlns:xsi=""
            <Setting Property="Telerik.WinControls.UI.RadListBoxItem.IsHighlighted" Value="True" /> 

    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. Kevin Meyer
    Kevin Meyer avatar
    36 posts
    Member since:
    Dec 2007

    Posted 02 Apr 2009 Link to this post

    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.
  3. Nick
    Nick avatar
    767 posts

    Posted 03 Apr 2009 Link to this post

    Hi Kevin Meyer,

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

    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Back to Top