diff --git a/WPF控件.sln b/WPF控件.sln index 7c5543e..1162007 100644 --- a/WPF控件.sln +++ b/WPF控件.sln @@ -48,6 +48,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF绑定元素-1-示例", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF绑定元素-1-代码模式的绑定", "WPF绑定元素-1-代码模式的绑定\WPF绑定元素-1-代码模式的绑定.csproj", "{715FDA75-3236-4011-B1DA-46BD3EAFBA37}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF绑定元素-2-代码检索绑定", "WPF绑定元素-2-代码检索绑定\WPF绑定元素-2-代码检索绑定.csproj", "{5797E06A-32B3-4F16-BC46-D88C8E5A5F48}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -150,5 +152,9 @@ Global {715FDA75-3236-4011-B1DA-46BD3EAFBA37}.Debug|Any CPU.Build.0 = Debug|Any CPU {715FDA75-3236-4011-B1DA-46BD3EAFBA37}.Release|Any CPU.ActiveCfg = Release|Any CPU {715FDA75-3236-4011-B1DA-46BD3EAFBA37}.Release|Any CPU.Build.0 = Release|Any CPU + {5797E06A-32B3-4F16-BC46-D88C8E5A5F48}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {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 EndGlobalSection EndGlobal diff --git a/WPF绑定元素-2-代码检索绑定/App.xaml b/WPF绑定元素-2-代码检索绑定/App.xaml new file mode 100644 index 0000000..686b1bf --- /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..c403390 --- /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..cac4f2d --- /dev/null +++ b/WPF绑定元素-2-代码检索绑定/MainWindow.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + \ 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..655d05d --- /dev/null +++ b/WPF绑定元素-2-代码检索绑定/MainWindow.xaml.cs @@ -0,0 +1,30 @@ +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(); + } + + private void ButtonBase_OnClick(object sender, RoutedEventArgs e) + { + var binding = BindingOperations.GetBinding(SampleTextBlock, TextBlock.FontSizeProperty); + Console.WriteLine(binding); + } + + private void ExpressionButton_OnClick(object sender, RoutedEventArgs e) + { + var bindingExpression = BindingOperations.GetBindingExpression(SampleTextBlock, TextBlock.FontSizeProperty); + var resolvedSource = (Slider)bindingExpression!.ResolvedSource; + var sourceFontSize = resolvedSource.FontSize; + Console.WriteLine(sourceFontSize); + } +} \ 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..6422a80 --- /dev/null +++ b/WPF绑定元素-2-代码检索绑定/WPF绑定元素-2-代码检索绑定.csproj @@ -0,0 +1,18 @@ + + + + WinExe + net8.0-windows + WPF绑定元素_2_代码检索绑定 + enable + enable + true + + + + + Always + + + + diff --git a/WPF绑定元素-2-代码检索绑定/public/003540AH4M72.jpg b/WPF绑定元素-2-代码检索绑定/public/003540AH4M72.jpg new file mode 100644 index 0000000..4aa96ac Binary files /dev/null and b/WPF绑定元素-2-代码检索绑定/public/003540AH4M72.jpg differ