當前位置: 首頁>>代碼示例>>C#>>正文


C# Binding.ReadValue方法代碼示例

本文整理匯總了C#中Binding.ReadValue方法的典型用法代碼示例。如果您正苦於以下問題:C# Binding.ReadValue方法的具體用法?C# Binding.ReadValue怎麽用?C# Binding.ReadValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Binding的用法示例。


在下文中一共展示了Binding.ReadValue方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ApplyWriteRules

    private void ApplyWriteRules(
      Control ctl, Binding binding,
      bool canWrite)
    {
      if (ctl is Label) return;

      // enable/disable writing of the value
      PropertyInfo propertyInfo =
        ctl.GetType().GetProperty("ReadOnly",
        BindingFlags.FlattenHierarchy |
        BindingFlags.Instance |
        BindingFlags.Public);
      if (propertyInfo != null)
      {
        bool couldWrite =
          (!(bool)propertyInfo.GetValue(
          ctl, new object[] { }));
        propertyInfo.SetValue(
          ctl, !canWrite, new object[] { });
        if ((!couldWrite) && (canWrite))
          binding.ReadValue();
      }
      else
      {
        bool couldWrite = ctl.Enabled;
        ctl.Enabled = canWrite;
        if ((!couldWrite) && (canWrite))
          binding.ReadValue();
      }
    }
開發者ID:transformersprimeabcxyz,項目名稱:cslacontrib-MarimerLLC,代碼行數:30,代碼來源:ReadWriteAuthorization.cs

示例2: ApplyReadRules

    private void ApplyReadRules(
      Control ctl, Binding binding,
      bool canRead)
    {
      var status = GetControlStatus(ctl);

      // enable/disable reading of the value
      if (canRead)
      {
        ctl.Enabled = true;
        // if !CanRead remove format event and refresh value 
        if (!status.CanRead)
        {
          binding.Format -= ReturnEmpty;
          binding.ReadValue();
        }
      }
      else
      {
        ctl.Enabled = false;
        if (status.CanRead)
        {
          binding.Format += ReturnEmpty;
        }

        // clear the value displayed by the control
        var propertyInfo = ctl.GetType().GetProperty(binding.PropertyName,
          BindingFlags.FlattenHierarchy |
          BindingFlags.Instance |
          BindingFlags.Public);
        if (propertyInfo != null)
        {
          propertyInfo.SetValue(ctl,
            GetEmptyValue(
            Utilities.GetPropertyType(
              propertyInfo.PropertyType)),
            new object[] { });
        }
      }

      // store new status
      status.CanRead = canRead;
    }
開發者ID:transformersprimeabcxyz,項目名稱:cslacontrib-MarimerLLC,代碼行數:43,代碼來源:ReadWriteAuthorization.cs


注:本文中的Binding.ReadValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。