3

I have this datagridtemplatecolumn of mine which I would like to bind to a property on my project page which has a type of System.Windows.Visibility. The problem is that whenever im compiling the XAML Below is it throws me an error like this in blend: "System.Windows.Data.Binding cannot be converted to System.Windows.Visibility" and in Runtime it throws an error like this 'Set property 'System.Windows.Controls.DataGridColumn.Visibility' threw an exception.'

<sdk:DataGridTemplateColumn Header="Settings" IsReadOnly="True" Visibility="{Binding ElementName=projectPage, btnEditVisibility}">
    <sdk:DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <Grid x:Name="grdEditCell" ToolTipService.ToolTip="Edit Project" >
                <sdk:Label Content="Edit" IsEnabled="{Binding isBtnEditEnabled, ElementName=projectPage}" Visibility="{Binding btnEditVisibility, ElementName=projectPage}" HorizontalAlignment="Center" VerticalAlignment="Center" MouseLeftButtonDown="btnEditProject_Click"/>
            </Grid>
        </DataTemplate>
    </sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>

H.B.
  • 166,899
  • 29
  • 327
  • 400
Allan Chua
  • 9,305
  • 9
  • 41
  • 61
  • What is `projectPage` and where is it placed? – Anatolii Gabuza Jan 30 '12 at 10:53
  • @anatoliiG projectPage is the name of the page where I had declared a property of type System.Windows.Controls.Visibility and it is also implemented with a property wrapper. I had also impelemented INotifyPropertyChanged Interface on the page. – Allan Chua Jan 30 '12 at 12:35

1 Answers1

1

What is the grids's ItemsSource set to? Do the same rules apply with element binding where you'd need to use a relative source binding. Also, what is btnEditVisibility? If its a button wouldn't you needed specify the buttons visibility property or use a SomethingToVisibility converter?

Post some more code if possible.

Derek Beattie
  • 9,429
  • 4
  • 30
  • 44
  • DataGrid's ItemsSource was binded to a domain context, Enabled and Visibility were properties that were impelemented in the projectPage(the page that i am using). – Allan Chua Jan 30 '12 at 12:45