Hi David,
I'm pasting my reply from the support ticket here:
If you need to use the custom RadListBoxItem when binding the ItemsSource you would need to implement a custom RadListBox and override the following methods:
public class CustomListBox : RadListBox
{
protected override DependencyObject GetContainerForItemOverride()
{
return new CustomListBoxItem();
}
protected override bool IsItemItsOwnContainerOverride(object item)
{
return item is CustomListBoxItem;
}
}
Regards,
Kalin
That's fine, but how do you tell the RadListBox to use the CustomRadListBoxItem. I'm already using ItemTemplates, if that matters in how this is done.
As workaround a custom ListBoxItem can be used instead - the TryFocus method should be overridden as shown below:
public class CustomListBoxItem : RadListBoxItem
{
protected override void TryFocus()
{
var focusedElement = FocusManagerHelper.GetFocusedElement(this) as UIElement;
if (focusedElement == null ||
!(focusedElement != this &&
this.IsAncestorOf(focusedElement) &&
!(focusedElement is RadListBoxItem)))
{
this.Focus();
}
}
}
Regards,
Kalin