feat: WPF路由事件-1-引发路由事件
This commit is contained in:
parent
95df7bdef1
commit
cc2ba06ebe
|
@ -52,6 +52,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF基础-10-布局示例",
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF基础-11-动态布局", "WPF基础-11-动态布局\WPF基础-11-动态布局.csproj", "{376F75D0-937A-46A3-99E6-7260DD975D93}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF路由事件-1-引发路由事件", "WPF路由事件-1-引发路由事件\WPF路由事件-1-引发路由事件.csproj", "{1B8F7458-502C-45A7-9C47-1EF772DD7E19}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -162,5 +164,9 @@ Global
|
|||
{376F75D0-937A-46A3-99E6-7260DD975D93}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{376F75D0-937A-46A3-99E6-7260DD975D93}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{376F75D0-937A-46A3-99E6-7260DD975D93}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1B8F7458-502C-45A7-9C47-1EF772DD7E19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1B8F7458-502C-45A7-9C47-1EF772DD7E19}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1B8F7458-502C-45A7-9C47-1EF772DD7E19}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1B8F7458-502C-45A7-9C47-1EF772DD7E19}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<Application x:Class="WPF路由事件_1_引发路由事件.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:WPF路由事件_1_引发路由事件"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
|
@ -0,0 +1,12 @@
|
|||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Windows;
|
||||
|
||||
namespace WPF路由事件_1_引发路由事件;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
|
@ -0,0 +1,19 @@
|
|||
<Window x:Class="WPF路由事件_1_引发路由事件.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="800" Width="400">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<Image Source="public/images/003540AH4M72.jpg" Width="322" Stretch="Uniform"
|
||||
MouseUp="GridImage_OnMouseUp" />
|
||||
|
||||
<Image Grid.Row="1" Margin="0 8 0 0 " Source="public/images/003540AH4M72.jpg" Width="322" Stretch="Uniform"
|
||||
Name="GridImage2" />
|
||||
</Grid>
|
||||
</Window>
|
|
@ -0,0 +1,30 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace WPF路由事件_1_引发路由事件;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// 等同于xaml上触发事件
|
||||
GridImage2.MouseUp += GridImage_OnMouseUp;
|
||||
|
||||
// 也可以这样创建事件
|
||||
GridImage2.AddHandler(MouseUpEvent, new MouseButtonEventHandler(GridImage_OnMouseUp));
|
||||
|
||||
// 移除事件
|
||||
GridImage2.MouseUp -= GridImage_OnMouseUp;
|
||||
GridImage2.RemoveHandler(MouseUpEvent, new MouseButtonEventHandler(GridImage_OnMouseUp));
|
||||
}
|
||||
|
||||
private void GridImage_OnMouseUp(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
Console.WriteLine(e.Timestamp);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<RootNamespace>WPF路由事件_1_引发路由事件</RootNamespace>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Resource Include="public\images\003540AH4M72.jpg">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Resource>
|
||||
<Resource Include="public\logo\1.ico">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Resource>
|
||||
<Resource Include="public\logo\1.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Resource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Binary file not shown.
After Width: | Height: | Size: 97 KiB |
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
Loading…
Reference in New Issue