使用Javascript进行原型设计(Prototyping in Javascript)
在原型语言中,对象基本上可以相互克隆。
所以,让我们说我们有一个构造函数:
Bla = function() { this.a = 1; }
我可以像这样创建一个新的对象实例:
x = new Bla();
。 现在,xa
返回1。如果我要写
Bla.prototype.b = 2
,那么xb
将返回2.但是,为什么? 如果x“克隆”Bla, 为什么我不能仅仅说Bla.b = 2
,而没有引用Bla.prototype
,并且仍然获得相同的功能? 这是否与this
关键字有关?In prototypal languages object can basically clone each other.
So, lets say we have a constructor function:
Bla = function() { this.a = 1; }
I can create a new instance of that object like this:
x = new Bla();
. Now,x.a
returns 1.If I were to write
Bla.prototype.b = 2
, thenx.b
would return 2. But, why? If x "cloned" Bla, why can't I just say thatBla.b = 2
, without referencing theBla.prototype
, and still get the same functionality? Does this have something to do with thethis
keyword?
原文:https://stackoverflow.com/questions/11066328
最满意答案
实际上我认为你不能使用两个DataTemplates。 尝试创建一个父模板和一个基于父模板的子模板。 更改模板使用:
DataTemplate summary = this.FindResource("SimpleTemplate") as DataTemplate; YourControl.ItemTemplate = summary;
Actually I don't think you can marge two DataTemplates. Try create one parent template and one child which base on parent template. Change template use:
DataTemplate summary = this.FindResource("SimpleTemplate") as DataTemplate; YourControl.ItemTemplate = summary;
相关问答
更多-
这是我的解决方案使用你的代码,请尝试检查这一点。 XAML尝试使用这段代码来访问ContentPresenter中的控件: public static FrameworkElement GetControlByName(DependencyObject parent, string name) { int count = VisualTreeHelper.GetChildrenCount(parent); for (var i = 0; i < count; ++i) { va ...在ContentControl的ControlTemplate ,通常使用空的ContentPresenter标记。 在你的情况下:实际上我认为你不能使用两个DataTemplates。 尝试创建一个父模板和一个基于父模板的子模板。 更改模板使用: DataTemplate summary = this.FindResource("SimpleTemplate") as DataTemplate; YourControl.ItemTemplate = summary; Actually I don't think you can marge two DataTemplates. Try create one parent templa ...
WPF DataTemplate / ControlTemplate和VS2008设计器(WPF DataTemplate/ControlTemplate and VS2008 designer)[2023-07-27]
斯特凡, 我认为您可以通过创建Design Time类来完成此操作,如下面的链接所述: http://karlshifflett.wordpress.com/2008/10/11/viewing-design-time-data-in-visual-studio-2008-cider-designer-in-wpf-and-silverlight-projects/ 希望这可以帮助。 Stefan, I think that you can do this by creating Design Time c ...DataTemplate未应用(DataTemplate not being applied)[2024-02-08]
您是否有机会在datatemplate中定义x:Key。 如果是这样,将导致内容演示者不使用datatemplate。 这是我最近遇到的一个问题。 By any chance do you have an x:Key defined in your datatemplate. If so that will cause the content presenter not to use the datatemplate. It was an issue I had recently.感谢来自@Bob的helfupful评论,我解决了这样的问题: 我在UserControl定义了一个属性,我拥有TreeView 。 我改变了1级的HierarchicalDataTemplate ,如下所示:要强制绑定刷新UI,请调用BindingExpression.UpdateTarget。 要获取给定元素的绑定表达式(在您的情况下,我假设一个ItemsSource),请使用BindingOperations.GetBindingExpression。 例如 BindingExpression bindingExpr = BindingOperations.GetBindingExpression(linksListBox, ListBox.ItemsSourceProperty); bindingExpr ...使用ControlTemplate而不是DataTemplate我对CheckBox.Template外观并不完全清楚。 Icons:ExIcon Control对我来说也是一个谜。 无论如何这里是一个小工作的例子。 它使用Rectangle而不是ExIcon。 但你可以很容易地替换它;-)我通过DataTrigger直接绑定到DataTrigger而不是通过ElementName或RelativeSource搜索。 XAML:... 相关文章
更多- javascript 问题
- javascript的验证
- 请教javascript问题
- javascript 注释
- javascript 基本语法
- JavaScript 事件
- JavaScript 事件
- javascript url编码
- javascript常用对象
- 《JavaScript模式》(JavaScript Patterns)扫描版[PDF]
最新问答
更多- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。