WPF PRISM 6 – EventToCommand Example

Benötigter Namespace:
xmlns:i=“http://schemas.microsoft.com/expression/2010/interactivity“

<i:Interaction.Triggers>
   <i:EventTrigger EventName="Loaded">
       <i:InvokeCommandAction Command="{Binding InitializeAnalyseViewCommand}" />
   </i:EventTrigger>
</i:Interaction.Triggers>

Einfügen innerhalb des Controls, bei dessen Event das Command ausgeführt werden soll.

WPF DataGrid – Beispiel DataGridTemplateColumn mit CheckBox und CommandBinding

 <DataGridTemplateColumn Header="Erledigt?" IsReadOnly="False">

                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>

                                <CheckBox Command="{Binding Path=DataContext.SetErledigtCommand,
                                                            RelativeSource={RelativeSource FindAncestor,
                                                                                           AncestorType={x:Type DataGrid}}}"
                                          CommandParameter="{Binding ElementName=DgSource,
                                                                     Path=SelectedItem}"
                                          IsChecked="{Binding DataContext.Erledigt,
                                                              UpdateSourceTrigger=PropertyChanged}" />



                            </DataTemplate>

                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>