views:

260

answers:

0

I have a button which is inside a DataGridTemplateColumn, in which I am placing an Image. This image initializes to a minus "-" sign image, indicating that you can click on the image and collapse some of the rows below it. Here's my question: what is the best way to switch the image's Source to the plus.png image?

XAML

<data:DataGridTemplateColumn.CellTemplate>
  <DataTemplate>

     <StackPanel Orientation="Horizontal" Margin="{Binding IndentPadding}">

        <Button Click="HideButton_Click" 
                Visibility="{Binding ShowExpandCollapse}" 
                VerticalAlignment="Center" 
                Width="12" Height="15" 
                Padding="0" Margin="3,0,3,0">
           <Button.Template>
             <ControlTemplate>

               <Image Source="minus.png" Height="9" Width="9" />

             </ControlTemplate>
           </Button.Template>
         </Button>

         <TextBlock Text="{Binding FirstName}" 
                    VerticalAlignment="Center" />

       </StackPanel>

     </DataTemplate>
   </data:DataGridTemplateColumn.CellTemplate>

Event Handler

Private Sub HideButton_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)

  If Not hiddenParents.Contains(CType(sender.DataContext, Data)) Then

    hiddenParents.Add(CType(sender.DataContext, Data))
    ToggleChildrenVisibility(CType(sender.DataContext, Data), False)

  Else

    hiddenParents.Remove(CType(sender.DataContext, Data))
    ToggleChildrenVisibility(CType(sender.DataContext, Data), True)

  End If

End Sub