I'm having a problem with my dependency property. It seems like it doesn't want to work at all, and I don't know why. Here is the code for my dependency property:
public static readonly DependencyProperty CheckBoxColumnVisibilityProperty =
DependencyProperty.Register("CheckBoxColumnVisibility", typeof(Visibility), typeof(ComputersControl), null);
public Visibility CheckBoxColumnVisibility
{
get
{
return (Visibility)GetValue(CheckBoxColumnVisibilityProperty);
}
set
{
SetValue(CheckBoxColumnVisibilityProperty, value);
}
}
Here is where I assign the value of my dependency property:
<ComputerControl:ComputersControl Canvas.Left="50" BorderBrush="Black" Background="Blue" Name="computerControl" CheckBoxColumnVisibility="Collapsed" />
Here is where I am trying to bind it to a column in a DataGrid
to make it so I can set that column to be visible or collapsed:
<Data:DataGrid.Columns>
<Data:DataGridTemplateColumn
x:Name="CheckBoxColumn"
Visibility="{Binding CheckBoxColumnVisibility}"
Header="Selected">
<Data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox x:Name="DataGridCheckBox"
Click="DataGridCheckBox_Click"
IsChecked="{Binding IsSelected, Mode=TwoWay}"
HorizontalAlignment="Center" />
</DataTemplate>
</Data:DataGridTemplateColumn.CellTemplate>
</Data:DataGridTemplateColumn>
Can someone tell my why it isn't working? Every example I look at looks exactly the same as this, but mine doesn't work...