diff --git a/WPF基础.sln b/WPF基础.sln index 67802f0..24f70da 100644 --- a/WPF基础.sln +++ b/WPF基础.sln @@ -66,6 +66,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF路由事件-6-获取键 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF路由事件-7-鼠标状态", "WPF路由事件-7-鼠标状态\WPF路由事件-7-鼠标状态.csproj", "{DA1459AB-F6F2-4657-B485-3F55F43B6812}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF路由事件-8-鼠标拖拽", "WPF路由事件-8-鼠标拖拽\WPF路由事件-8-鼠标拖拽.csproj", "{C88744AA-839B-473A-9A0D-DD9171AAA0AC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -204,5 +206,9 @@ Global {DA1459AB-F6F2-4657-B485-3F55F43B6812}.Debug|Any CPU.Build.0 = Debug|Any CPU {DA1459AB-F6F2-4657-B485-3F55F43B6812}.Release|Any CPU.ActiveCfg = Release|Any CPU {DA1459AB-F6F2-4657-B485-3F55F43B6812}.Release|Any CPU.Build.0 = Release|Any CPU + {C88744AA-839B-473A-9A0D-DD9171AAA0AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C88744AA-839B-473A-9A0D-DD9171AAA0AC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C88744AA-839B-473A-9A0D-DD9171AAA0AC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C88744AA-839B-473A-9A0D-DD9171AAA0AC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/WPF路由事件-8-鼠标拖拽/App.xaml b/WPF路由事件-8-鼠标拖拽/App.xaml new file mode 100644 index 0000000..6f4b3b3 --- /dev/null +++ b/WPF路由事件-8-鼠标拖拽/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/WPF路由事件-8-鼠标拖拽/App.xaml.cs b/WPF路由事件-8-鼠标拖拽/App.xaml.cs new file mode 100644 index 0000000..9f5ed94 --- /dev/null +++ b/WPF路由事件-8-鼠标拖拽/App.xaml.cs @@ -0,0 +1,12 @@ +using System.Configuration; +using System.Data; +using System.Windows; + +namespace WPF路由事件_8_鼠标拖拽; + +/// +/// Interaction logic for App.xaml +/// +public partial class App : Application +{ +} \ No newline at end of file diff --git a/WPF路由事件-8-鼠标拖拽/AssemblyInfo.cs b/WPF路由事件-8-鼠标拖拽/AssemblyInfo.cs new file mode 100644 index 0000000..4a05c7d --- /dev/null +++ b/WPF路由事件-8-鼠标拖拽/AssemblyInfo.cs @@ -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) +)] \ No newline at end of file diff --git a/WPF路由事件-8-鼠标拖拽/MainWindow.xaml b/WPF路由事件-8-鼠标拖拽/MainWindow.xaml new file mode 100644 index 0000000..98955ca --- /dev/null +++ b/WPF路由事件-8-鼠标拖拽/MainWindow.xaml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/WPF路由事件-8-鼠标拖拽/MainWindow.xaml.cs b/WPF路由事件-8-鼠标拖拽/MainWindow.xaml.cs new file mode 100644 index 0000000..c99c62a --- /dev/null +++ b/WPF路由事件-8-鼠标拖拽/MainWindow.xaml.cs @@ -0,0 +1,27 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; + +namespace WPF路由事件_8_鼠标拖拽; + +/// +/// Interaction logic for MainWindow.xaml +/// +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + } + + private void LabelDrop1_OnDrop(object sender, DragEventArgs e) + { + e.Effects = e.Data.GetDataPresent(DataFormats.Text) ? DragDropEffects.Copy : DragDropEffects.None; + } + + private void LabelDrop1_OnMouseDown(object sender, MouseButtonEventArgs e) + { + var label = (Label)sender; + DragDrop.DoDragDrop(label, LabelDrop1.Content, DragDropEffects.Copy); + } +} \ No newline at end of file diff --git a/WPF路由事件-8-鼠标拖拽/WPF路由事件-8-鼠标拖拽.csproj b/WPF路由事件-8-鼠标拖拽/WPF路由事件-8-鼠标拖拽.csproj new file mode 100644 index 0000000..8fe0b78 --- /dev/null +++ b/WPF路由事件-8-鼠标拖拽/WPF路由事件-8-鼠标拖拽.csproj @@ -0,0 +1,12 @@ + + + + WinExe + net8.0-windows + WPF路由事件_8_鼠标拖拽 + enable + enable + true + + +