From d360e583d2636352711cc60c62e4666703119a8d Mon Sep 17 00:00:00 2001 From: "David P.G" Date: Thu, 10 Jul 2025 12:26:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DDataGrid=E5=88=97=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E6=98=AF=E5=90=A6=E6=98=BE=E7=A4=BA=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Extensions/BindingProxy.cs | 22 ++++++++++++++++++++++ Views/VariableTableView.xaml | 18 +++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 Extensions/BindingProxy.cs diff --git a/Extensions/BindingProxy.cs b/Extensions/BindingProxy.cs new file mode 100644 index 0000000..d394fc1 --- /dev/null +++ b/Extensions/BindingProxy.cs @@ -0,0 +1,22 @@ +using System.Windows; + +namespace PMSWPF.Extensions +{ + public class BindingProxy : Freezable + { + // Using a DependencyProperty as the backing store for Data. This enables animation, styling, binding, etc... + public static readonly DependencyProperty DataProperty = + DependencyProperty.Register("Data", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null)); + + public object Data + { + get { return (object)GetValue(DataProperty); } + set { SetValue(DataProperty, value); } + } + + protected override Freezable CreateInstanceCore() + { + return new BindingProxy(); + } + } +} \ No newline at end of file diff --git a/Views/VariableTableView.xaml b/Views/VariableTableView.xaml index 8803c94..8fe796b 100644 --- a/Views/VariableTableView.xaml +++ b/Views/VariableTableView.xaml @@ -16,6 +16,7 @@ d:DesignHeight="600" d:DesignWidth="800"> + + + + + Header="S7地址" + Visibility="{Binding Source={StaticResource proxy}, Path=Data.IsS7ProtocolSelected, Converter={StaticResource BooleanToVisibilityConverter}}" + Binding="{Binding S7Address}" /> + @@ -288,6 +297,7 @@ @@ -308,9 +318,7 @@ - +