From 22fd309abc55c17283ad9e6f4314348df4190e15 Mon Sep 17 00:00:00 2001 From: Bunny <1319900154@qq.com> Date: Thu, 9 Jan 2025 16:24:27 +0800 Subject: [PATCH] =?UTF-8?q?WPF=E7=BB=91=E5=AE=9A=E5=85=83=E7=B4=A0-2-?= =?UTF-8?q?=E5=A4=9A=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WPF控件.sln | 6 ++++ WPF绑定元素-2-多绑定/App.xaml | 9 +++++ WPF绑定元素-2-多绑定/App.xaml.cs | 12 +++++++ WPF绑定元素-2-多绑定/AssemblyInfo.cs | 10 ++++++ WPF绑定元素-2-多绑定/MainWindow.xaml | 34 +++++++++++++++++++ WPF绑定元素-2-多绑定/MainWindow.xaml.cs | 26 ++++++++++++++ .../WPF绑定元素-2-多绑定.csproj | 12 +++++++ 7 files changed, 109 insertions(+) create mode 100644 WPF绑定元素-2-多绑定/App.xaml create mode 100644 WPF绑定元素-2-多绑定/App.xaml.cs create mode 100644 WPF绑定元素-2-多绑定/AssemblyInfo.cs create mode 100644 WPF绑定元素-2-多绑定/MainWindow.xaml create mode 100644 WPF绑定元素-2-多绑定/MainWindow.xaml.cs create mode 100644 WPF绑定元素-2-多绑定/WPF绑定元素-2-多绑定.csproj diff --git a/WPF控件.sln b/WPF控件.sln index 1162007..920fe32 100644 --- a/WPF控件.sln +++ b/WPF控件.sln @@ -50,6 +50,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF绑定元素-1-代码模 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF绑定元素-2-代码检索绑定", "WPF绑定元素-2-代码检索绑定\WPF绑定元素-2-代码检索绑定.csproj", "{5797E06A-32B3-4F16-BC46-D88C8E5A5F48}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF绑定元素-2-多绑定", "WPF绑定元素-2-多绑定\WPF绑定元素-2-多绑定.csproj", "{610A264F-5995-4667-8FD9-3494481928FF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -156,5 +158,9 @@ Global {5797E06A-32B3-4F16-BC46-D88C8E5A5F48}.Debug|Any CPU.Build.0 = Debug|Any CPU {5797E06A-32B3-4F16-BC46-D88C8E5A5F48}.Release|Any CPU.ActiveCfg = Release|Any CPU {5797E06A-32B3-4F16-BC46-D88C8E5A5F48}.Release|Any CPU.Build.0 = Release|Any CPU + {610A264F-5995-4667-8FD9-3494481928FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {610A264F-5995-4667-8FD9-3494481928FF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {610A264F-5995-4667-8FD9-3494481928FF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {610A264F-5995-4667-8FD9-3494481928FF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/WPF绑定元素-2-多绑定/App.xaml b/WPF绑定元素-2-多绑定/App.xaml new file mode 100644 index 0000000..f8d3c6b --- /dev/null +++ b/WPF绑定元素-2-多绑定/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/WPF绑定元素-2-多绑定/App.xaml.cs b/WPF绑定元素-2-多绑定/App.xaml.cs new file mode 100644 index 0000000..c93584f --- /dev/null +++ b/WPF绑定元素-2-多绑定/App.xaml.cs @@ -0,0 +1,12 @@ +using System.Configuration; +using System.Data; +using System.Windows; + +namespace WPF绑定元素_2_多绑定; + +/// +/// Interaction logic for App.xaml +/// +public partial class App : Application +{ +} \ No newline at end of file diff --git a/WPF绑定元素-2-多绑定/AssemblyInfo.cs b/WPF绑定元素-2-多绑定/AssemblyInfo.cs new file mode 100644 index 0000000..4a05c7d --- /dev/null +++ b/WPF绑定元素-2-多绑定/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绑定元素-2-多绑定/MainWindow.xaml b/WPF绑定元素-2-多绑定/MainWindow.xaml new file mode 100644 index 0000000..5dddd1b --- /dev/null +++ b/WPF绑定元素-2-多绑定/MainWindow.xaml @@ -0,0 +1,34 @@ + + + + + + 这是文字内容 + + + Pink + Red + Green + + + + + + + + + + \ No newline at end of file diff --git a/WPF绑定元素-2-多绑定/MainWindow.xaml.cs b/WPF绑定元素-2-多绑定/MainWindow.xaml.cs new file mode 100644 index 0000000..4eab217 --- /dev/null +++ b/WPF绑定元素-2-多绑定/MainWindow.xaml.cs @@ -0,0 +1,26 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; + +namespace WPF绑定元素_2_多绑定; + +/// +/// Interaction logic for MainWindow.xaml +/// +public partial class MainWindow : Window +{ + public MainWindow() + { + InitializeComponent(); + + // 创建一个 Binding 对象 + var binding = new Binding("Value") + { + Source = TextBlockSlider, + Delay = 500 // 设置延迟时间 + }; + + // 将 Binding 应用到 TextBox 的 Text 属性上 + ExactSizeForSlider.SetBinding(TextBox.TextProperty, binding); + } +} \ No newline at end of file diff --git a/WPF绑定元素-2-多绑定/WPF绑定元素-2-多绑定.csproj b/WPF绑定元素-2-多绑定/WPF绑定元素-2-多绑定.csproj new file mode 100644 index 0000000..880ca67 --- /dev/null +++ b/WPF绑定元素-2-多绑定/WPF绑定元素-2-多绑定.csproj @@ -0,0 +1,12 @@ + + + + WinExe + net8.0-windows + WPF绑定元素_2_多绑定 + enable + enable + true + + +