这是一个 Wpf 应用程序,我创建了 6 个图像。单击每个图像我想显示一个页面。Xaml 代码与此类似。
<Controls:ReflectionControl Grid.Row="2">
<ItemsControl ItemsSource="{Binding Path=DashBoardApps}" VerticalAlignment="Bottom" HorizontalAlignment="Center">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Controls:FishEyeControl />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock x:Name="txtAppName" Text="{Binding Path=ApplicationName}" TextAlignment="Center" Visibility="Hidden" FontSize="7px" Foreground="#eff7ff" />
<Image Source="{Binding Path=ApplicationImage}" Height="32" Width="32" MouseLeftButtonDown="Image_MouseLeftButtonDown_1"/>
</StackPanel>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="txtAppName" Property="Visibility" Value="Visible" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Controls:ReflectionControl>
我已关联事件
MouseLeftButtonDown
至
Image_MouseLeftButtonDown_1
cs代码:
private void Image_MouseLeftButtonDown_1(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
UserControl2 uc2 = new UserControl2();
pageTransitionControl.ShowPage(uc2);
canvas1.Visibility = System.Windows.Visibility.Hidden;
//canvas2.Visibility = System.Windows.Visibility.Visible;
canvas3.Visibility = System.Windows.Visibility.Hidden;
}
我想识别每个事件的来源(生成事件的图像)并分配类似于上述代码的代码。我该怎么做?