Help with ItemsControl Event Handler
Posted: 30 Jun 2014, 16:51
I'm not sure how to go about having an event handler on a child item of an ItemsControl using a DataTemplate.
For example how could I make it where when a user clicks an item in the stackpanel it fires off an event.
Here is my xaml for the ItemsControl:
For example how could I make it where when a user clicks an item in the stackpanel it fires off an event.
Here is my xaml for the ItemsControl:
Code: Select all
<ItemsControl x:Name="BlueTeam" Grid.Column="0" Grid.Row="1" Grid.RowSpan="2" Margin="0,0,0,1">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Height="25" Margin="1">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<LinearGradientBrush.RelativeTransform>
<TransformGroup>
<RotateTransform Angle="-90" CenterY="0.5" CenterX="0.5" />
<TranslateTransform />
</TransformGroup>
</LinearGradientBrush.RelativeTransform>
<GradientStop Color="#7F1059B2" Offset="0" />
<GradientStop Offset="1" />
</LinearGradientBrush>
</Border.Background>
<Grid>
<TextBlock VerticalAlignment="Center" Text="{Binding Name}" TextAlignment="Left" Padding="20,0,0,0" Foreground="#fff" TextWrapping="Wrap" />
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>