Hi, I need extend RadComboBoxItem to prevent DropDownClose (in some cases).
I added this class:
Idea is to trigger base implementation of MouseLeftButtonUp only if necessary.
But when I try use this class in XAML:
I get XamlParseException in RadComboBox PrepareContainerForItemOverride. I don't apply any styles or bindings in CustomComboBoxItem (but I also use DataTemplate), why I get this error? Is it possible to do such things?
Thanks for help!
I added this class:
public class CustomComboItem : RadComboBoxItem
{
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
{
var parentComboBox = ItemsControl.ItemsControlFromItemContainer(this) as RadComboBox;
if (parentComboBox != null)
{
var collection = parentComboBox.ItemsSource as ICustomCollection;
if (collection != null)
{
var item =
collection[parentComboBox.ItemContainerGenerator.IndexFromContainer(this)] as ICustomItem;
if (item != null && !item.IsSelectable)
return;
}
}
base.OnMouseLeftButtonUp(e);
}
}
Idea is to trigger base implementation of MouseLeftButtonUp only if necessary.
But when I try use this class in XAML:
<
Style
x:Key
=
"CustomComboBoxItem"
TargetType
=
"controls:CustomComboItem"
></
Style
>
<
Style
x:Key
=
"ComboBase"
TargetType
=
"controls:CustomCombo"
>
//other styles
<
Setter
Property
=
"ItemContainerStyle"
Value
=
"{StaticResource CustomComboBoxItem}"
></
Setter
>
//other styles
</
Style
>
I get XamlParseException in RadComboBox PrepareContainerForItemOverride. I don't apply any styles or bindings in CustomComboBoxItem (but I also use DataTemplate), why I get this error? Is it possible to do such things?
Thanks for help!