Hi there,
I have a custom MultiSelect attached property, I can use it with a ListBox however I can't seem to use it with your grid view, I get an error that say's property 'IsEnabled' is not attachable to type elements of type 'RadGridView' - Why would it work with a listbox but not a gridview? I mean, it's just an attached property - I don't see what the issue is with a the grid.
Here is the code for the MultiSelect.cs
Thanks for any help...
I have a custom MultiSelect attached property, I can use it with a ListBox however I can't seem to use it with your grid view, I get an error that say's property 'IsEnabled' is not attachable to type elements of type 'RadGridView' - Why would it work with a listbox but not a gridview? I mean, it's just an attached property - I don't see what the issue is with a the grid.
Here is the code for the MultiSelect.cs
public
static
class
MultiSelect
{
static
MultiSelect()
{
Selector.ItemsSourceProperty.OverrideMetadata(
typeof
(Selector),
new
FrameworkPropertyMetadata(ItemsSourceChanged));
}
public
static
bool
GetIsEnabled(Selector target)
{
return
(
bool
)target.GetValue(IsEnabledProperty);
}
public
static
void
SetIsEnabled(Selector target,
bool
value)
{
target.SetValue(IsEnabledProperty, value);
}
public
static
readonly
DependencyProperty IsEnabledProperty =
DependencyProperty.RegisterAttached(
"IsEnabled"
,
typeof
(
bool
),
typeof
(MultiSelect),
new
UIPropertyMetadata(IsEnabledChanged));
static
void
IsEnabledChanged(
object
sender, DependencyPropertyChangedEventArgs e)
{
Selector selector = sender
as
Selector;
IMultiSelectCollectionView collectionView = selector.ItemsSource
as
IMultiSelectCollectionView;
if
(selector !=
null
&& collectionView !=
null
)
{
if
((
bool
)e.NewValue)
{
collectionView.AddControl(selector);
}
else
{
collectionView.RemoveControl(selector);
}
}
}
static
void
ItemsSourceChanged(
object
sender, DependencyPropertyChangedEventArgs e)
{
Selector selector = sender
as
Selector;
if
(GetIsEnabled(selector))
{
IMultiSelectCollectionView oldCollectionView = e.OldValue
as
IMultiSelectCollectionView;
IMultiSelectCollectionView newCollectionView = e.NewValue
as
IMultiSelectCollectionView;
if
(oldCollectionView !=
null
)
{
oldCollectionView.RemoveControl(selector);
}
if
(newCollectionView !=
null
)
{
newCollectionView.AddControl(selector);
}
}
}
}