Hi there, I am trying to create a behavior I can use to set the width of certain columns to 0 if certain things happen but when I try to access the AssociatedObject it is always null. I think the code will better explain this...
It's fairly obvious what I want to do there however no matter what the
Thanks alot!!!
public
static
readonly
DependencyProperty VisibilityProperty =
DependencyProperty.Register(
"Visibility"
,
typeof
(
bool
),
typeof
(HideRadGridViewColumnBehavior),
new
PropertyMetadata(OnVisibilityPropertyChanged));
private
static
void
OnVisibilityPropertyChanged(DependencyObject target, DependencyPropertyChangedEventArgs args)
{
if
(((HideRadGridViewColumnBehavior)target).AssociatedObject ==
null
)
{
MessageBox.Show(
"AssociatedObject is null"
);
}
else
{
var col = ((HideRadGridViewColumnBehavior)target).AssociatedObject
as
GridViewDataColumn;
col.Width = 0;
col.Header =
""
;
col.IsResizable =
false
;
}
}
It's fairly obvious what I want to do there however no matter what the
AssociatedObject
is null, Here is the XAML I am using - hopefully someone can point me in the right direction on this. <
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding ModelId}"
Header
=
"ID"
>
<
i:Interaction.Behaviors
>
<
b:HideRadGridViewColumnBehavior
Visibility
=
"{Binding Path=DevMode}"
/>
</
i:Interaction.Behaviors
>
</
telerik:GridViewDataColumn
>
Thanks alot!!!