WPF Command-Bindung im DataTemplate

Ich bin mit ItemsControl zu halten meine Sammlung.
Die ItemsPanel ist ein Canvas, die ItemTemplate ist ein block von Border>StackPanel>TextBlocks
Ich will bind-Befehl in der DataTemplate zu fangen, klicken Sie auf einen block (item meiner Sammlung)

Code:

   <Grid Grid.Row="1" Grid.Column="1" >
        <ItemsControl ItemsSource="{Binding Products}">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <helpers:DragCanvas 
                        HorizontalAlignment="Stretch" 
                        VerticalAlignment="Stretch"
                        AllowDragging="True"
                        AllowDragOutOfView="False" />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <!-- The border and its content is what I see
                    on my canvas, I want to bind a command here (on click do something) -->
                    <Border BorderThickness="1" BorderBrush="Gold">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Path=Name}" />
                            <TextBlock Text="{Binding Path=Price}" />
                        </StackPanel>
                    </Border>
                </DataTemplate>
            </ItemsControl.ItemTemplate>    
        </ItemsControl>
    </Grid>

InformationsquelleAutor Stacked | 2014-07-22

Schreibe einen Kommentar