【问题标题】:Silverlight property bindingSilverlight 属性绑定
【发布时间】:2010-10-05 13:01:59
【问题描述】:

当绑定源的值为 156 时,有人可以帮我找出为什么 l.X1 设置为默认值(0.0)。下图可能是不言自明的。

【问题讨论】:

  • 所有东西都声明并运行在同一个线程上吗?我的猜测可能不是,这就是你看到这种行为的原因。需要更多代码来帮助 - 抱歉。
  • 所有东西都被声明并且在同一个线程上。
  • 如果我在 MyObj 类中注释掉以下行,一切都会按预期工作。但我需要这个属性是依赖属性。公共静态只读 DependencyProperty CenterXProperty = DependencyProperty.Register("CenterX", typeof(double), typeof(MyObj), null); public static readonly DependencyProperty CenterYProperty = DependencyProperty.Register("CenterY", typeof(double), typeof(MyObj), null);
  • 向我们展示您对 X1Property DependencyProperty 的声明。此外,向我们展示与 CenterX DependencyProperty 的绑定。
  • 我正在使用框架提供的相同 Line 类。我使用的唯一绑定在我的问题的图像中。

标签: c# silverlight-3.0 windows-phone-7


【解决方案1】:

http://forums.silverlight.net/forums/t/66005.aspx

我认为您不能将 DependencyProperty 用作 SilverLight 中的 BindingSource。请参阅上面的链接。

【讨论】:

  • 只是好奇,为什么 Framworkelement 暴露了一个名为 SetBinding(dp,binding).when 它不支持的方法
  • 我的理解是 WPF 确实支持 SetBinding() 到 Binding.Source 中的 DependencyProperty 对象,但 Silverlight 不支持。不过,我不会发誓。你能用 WPF 模拟一个测试吗?
  • CLR 集合方法中这些缺失的行导致了奇怪的结果。在 set 方法中,我使用了不同的附加属性。 SetValue(CenterXProperty, 值); SetValue(CenterYProperty, value);
【解决方案2】:

CLR 集合方法中这些缺失的行导致了奇怪的结果。在 set 方法中,我使用了不同的附加属性。 SetValue(CenterXProperty, 值); SetValue(CenterYProperty, value);

【讨论】:

    猜你喜欢
    • 2010-12-04
    • 2012-01-31
    • 2011-02-15
    • 1970-01-01
    • 2011-07-23
    • 1970-01-01
    • 1970-01-01
    • 2011-07-29
    • 2011-09-18
    相关资源
    最近更新 更多