Binding lack of the Silverlight DataGrid CellTemplate

Be aware of this.
Silverlight 5.
DataGrid
DataGridTemplateColumn.CellTemplate
Visibility (!!!)
It doesn’t work, at all:
Visibility="{Binding Path=Detail, Converter={StaticResource VisibleNonEmptyConverter}}"
This is working:
Visibility="{Binding Path=DataContext, RelativeSource={RelativeSource Self}, Converter={StaticResource VisibleNonEmptyConverter}}"
DataContext="{Binding Path=Detail}"
<data:DataGrid
               ItemsSource="{Binding Path=Items}"
               AutoGenerateColumns="False"
               HeadersVisibility="None"
               Background="Transparent"
               HorizontalAlignment="Left"
               HorizontalContentAlignment="Left"
               VerticalContentAlignment="Center"
               AlternatingRowBackground="LightGray"
               RowBackground="White"
               >
               <data:DataGrid.Columns>
                               <data:DataGridTextColumn Binding="{Binding Path=Name}" IsFrozen="True" IsReadOnly="True"/>
                                                                            
                               <data:DataGridTemplateColumn>
                                              <data:DataGridTemplateColumn.CellTemplate>
                                                             <DataTemplate>
                                                                            <Grid
                                                                                           VerticalAlignment="Center"
                                                                                           DataContext="{Binding Path=Value}"
                                                                                           >
                                                                                            <Grid.ColumnDefinitions>
                                                                                                           <ColumnDefinition/>
                                                                                                           <ColumnDefinition Width="auto"/>
                                                                                            </Grid.ColumnDefinitions>
                                                                                                                                          
                                                                                           <TextBlock Text="{Binding Path=Exact}" VerticalAlignment="Center" Margin="3 0"/>
                                                                                                                                          
                                                                                            <!--, FallbackValue=Collapsed, TargetNullValue=Collapsed-->
                                                                                            <Image
                                                                                                           Grid.Column="1"
                                                                                                           Source="/HCFB.UFO.Web;component/Resources/Images/info.v2.png"
                                                                                                           Width="16"
                                                                                                           Margin="3 1"
                                                                                                           VerticalAlignment="Center"
Visibility="{Binding Path=DataContext, RelativeSource={RelativeSource Self},
                    Converter={StaticResource VisibleNonEmptyConverter}, FallbackValue=Collapsed}"
DataContext="{Binding Path=Detail}"
                                                                                                           MouseLeftButtonUp="DetailImage_MouseLeftButtonUp"
                                                                                           />
                                                                            </Grid>
                                                             </DataTemplate>
                                              </data:DataGridTemplateColumn.CellTemplate>
                               </data:DataGridTemplateColumn>
               </data:DataGrid.Columns>
                                                             
</data:DataGrid>

Comments

Popular posts from this blog

Convention over Git = CoG

jQuery Deferred Object method chain or a Syntactic Sugar

Ctrl+Shift+Right arrow doesn't work in Visual Studio 2019