diff --git a/BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs b/BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs
index 3456a376..01d250f8 100644
--- a/BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs
+++ b/BPASmartClient.SCADAControl/CustomerControls/TheTextBlock.cs
@@ -90,38 +90,11 @@ namespace BPASmartClient.SCADAControl.CustomerControls
///
DispatcherTimer timer = new DispatcherTimer();
///
- /// 属性绑定变量集合
- ///
- Dictionary propertyBing = new Dictionary();
- ///
/// 运行事件
///
public void Register()
{
- //Binding binding = new Binding();
- //binding.RelativeSource = new RelativeSource() { Mode = RelativeSourceMode.Self };
- //binding.Path = new PropertyPath(string.Format("DataModel[{0}].通道校准参数2", "小配料机"));
- //SetBinding(TextProperty, binding);
-
- //Binding binding = new Binding();
- //binding.RelativeSource = new RelativeSource() { Mode = RelativeSourceMode.Self };
- //binding.Path = new PropertyPath("this");
- //SetBinding(DataContextProperty, binding);
-
- PropertyInfo[] propertyInfos = this.GetType().GetProperties();
- foreach (PropertyInfo propertyInfo in propertyInfos)
- {
- var propName = propertyInfo?.GetValue(this,null);
- if (propName is string && propName != null && propName.ToString().Contains("Binding ") && propName.ToString().Contains("."))
- {
- string va = string.Empty;
- if (propName.ToString().StartsWith("{}")) va = propName.ToString().Replace("{}","");
- else va = propName.ToString();
- propertyBing[propertyInfo.Name] = va;
- }
- }
-
- //if (propertyBing.Count > 0)
+ if (BindingOperations.GetBinding(this, TextProperty) != null)
{
timer.Interval = TimeSpan.FromMilliseconds(TimeCount);
timer.Tick += Timer_Tick; ;
@@ -138,21 +111,6 @@ namespace BPASmartClient.SCADAControl.CustomerControls
try
{
DataModel = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(Class_DataBus.GetInstance().Dic_RedisData));
-
- foreach (var item in propertyBing)
- {
- //{Binding 测试设备.VAR_A_2}
- string[] str = item.Value.Replace("{Binding ","").Replace("}","").Split(".");
- if (str.Length > 1)
- {
- DataModel = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(Class_DataBus.GetInstance().Dic_RedisData));
- if (Class_DataBus.GetInstance().Dic_RedisData.ContainsKey(str[0]))
- {
- Dictionary b = Class_DataBus.GetInstance().Dic_RedisData[str[0]];
- if (b != null && b.ContainsKey(str[1])) this.GetType().GetProperty(item.Key).SetValue(this, b[str[1]]);
- }
- }
- }
}
catch (Exception ex)
{
diff --git a/BeDesignerSCADA/ViewModel/MainViewModelNew.cs b/BeDesignerSCADA/ViewModel/MainViewModelNew.cs
index f26905a8..5d1edaa0 100644
--- a/BeDesignerSCADA/ViewModel/MainViewModelNew.cs
+++ b/BeDesignerSCADA/ViewModel/MainViewModelNew.cs
@@ -271,7 +271,12 @@ namespace BeDesignerSCADA.ViewModel
string _binding = PropertyBindingWindow.ShowEdit(dependencyProperty, (selectControl as FrameworkElement), VariablePath);
if (!string.IsNullOrEmpty(_binding))
{
- Binding bindingText = new Binding() { Mode = BindingMode.TwoWay, Path = new PropertyPath(_binding) };
+ Binding bindingText = new Binding()
+ {
+ Mode = BindingMode.TwoWay,
+ RelativeSource=new RelativeSource { Mode=RelativeSourceMode.Self},
+ Path = new PropertyPath(_binding)
+ };
(selectControl as FrameworkElement).SetBinding(dependencyProperty, bindingText);
}
else