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:
Notice, I'm trying to add the rad property to RadListBoxItem in the MultiSelectComboBoxElement static constructor.
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.
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)); |
- 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.