找到你要的答案

Q:Polymer - XAML DataContext Concept

Q:聚合物- XAML DataContext的概念

I am working on a XAML adaption for Polymer 1.x. Currently I have some elements and a xsl file to transform my xaml file to html with polymer. Custom elements are working but unfortunately the binding concept is a bit different. I tried several ideas to use the native binding concept but none of them worked.

Now I try a more deeper approach with far more work and as a beginner I better ask before this will fail ;)

  1. Bindings in xaml have the syntax {Binding Path=xyz}. In Polymer this will be stored as string in a property.

  2. Implement a mixin "DependencyObject" which will observe "this" when created.

  3. When a change event arrives check for xaml binding syntax.
  4. If it is a binding - create a path observer for the path in this binding on the DataContext property of the mixin.
  5. The outcome of the path observer should then be set to the binding.

Are there any obvious problems? Did someone make anything similar?

The path observer will be an external library because polymer 1.0 does not support it anymore?

I am working on a XAML adaption for Polymer 1.x. Currently I have some elements and a xsl file to transform my xaml file to html with polymer. Custom elements are working but unfortunately the binding concept is a bit different. I tried several ideas to use the native binding concept but none of them worked.

现在,我尝试更深入的方法与更多的工作,作为一个初学者,我最好问之前,这将失败;

  1. Bindings in xaml have the syntax {Binding Path=xyz}. In Polymer this will be stored as string in a property.

  2. 实现一个mixin”dependencyobject”将观察”这“当创建。

  3. When a change event arrives check for xaml binding syntax.
  4. If it is a binding - create a path observer for the path in this binding on the DataContext property of the mixin.
  5. The outcome of the path observer should then be set to the binding.

有什么明显的问题吗?有人做过类似的事吗?

路径观察将是一个外部库,因为聚合物1不支持它了吗?

answer1: 回答1:

You have to use Platform.performMicrotaskCheckpoint(); after every change of foo.bar, because Object,observe is not a blueprint anymore. Off for M50+

var foo = {
  bar: "hello"
}
var changes = [];
var observer = new ObjectObserver(foo);
observer.open(function(added) {
  changes.push(added);
}, foo);
foo.bar = "hi";

Platform.performMicrotaskCheckpoint();

你使用的平台。performmicrotaskcheckpoint();经过foo.bar,每变化因为对象,观察不是一个蓝图了。从M50 +

var foo = {
  bar: "hello"
}
var changes = [];
var observer = new ObjectObserver(foo);
observer.open(function(added) {
  changes.push(added);
}, foo);
foo.bar = "hi";

Platform.performMicrotaskCheckpoint();
xaml  xslt  polymer  datacontext