我在回调函数中引用我的对象时遇到了一些普通的旧JavaScript(没有框架)的问题.
function foo(id) {
this.dom = document.getElementById(id);
this.bar = 5;
var self = this;
this.dom.addEventListener("click", self.onclick, false);
}
foo.prototype = {
onclick : function() {
this.bar = 7;
}
};
Run Code Online (Sandbox Code Playgroud)
现在当我创建一个新对象时(在DOM加载后,使用span #test)
var x = new foo('test');
Run Code Online (Sandbox Code Playgroud)
onclick函数中的'this'指向span#test而不是foo对象.
如何在onclick函数中获取对foo对象的引用?
在WPF中Binding.Mode,选择默认值时,它取决于绑定的属性.
我正在寻找一些列表或一些约定或任何信息的各种控件的默认值.
我的意思是TwoWay,默认情况下属性是什么等等.任何链接,想法,想法,甚至咆哮都很受欢迎!
你能给我一个简单的后台服务应用程序示例,它使用bind/unbind方法来启动和停止它吗?我正在谷歌搜索半个小时,但这些示例使用startService/stopService方法或对我来说非常困难.谢谢.
在Common Lisp中你可以这样做:
(defun foo (bar &key baz quux)
(list bar baz quux))
(foo 1 :quux 3 :baz 2) ; => (1 2 3)
Run Code Online (Sandbox Code Playgroud)
Clojure没有关键字参数.一种选择是:
(defn foo [bar {:keys [baz quux]}]
(list bar baz quux))
(foo 1 {:quux 3 :baz 2}) ; => (1 2 3)
Run Code Online (Sandbox Code Playgroud)
这是太多的嵌套括号,必须一直打字和阅读.它还需要将显式散列映射作为参数而不是平面列表传递.
什么是最惯用的Clojure相当于关键字参数,看起来没有人引发标点炸弹?
对于值1,2或3,将一组3个radiobuttons绑定到int类型属性的最简单方法是什么?
我有一个宽度为"1*"的网格.所以我认为在运行时确定实际宽度.在该网格中,我有另一个网格,其宽度我想设置为父网格的运行时宽度.我怎么能通过绑定在xaml中做到这一点.
我似乎在圈子里跑来跑去,并且在过去的几个小时里一直这样做.
我想从一个字符串数组填充datagridview.我已经读过它不可能直接了,我需要创建一个将字符串保存为公共属性的自定义类型.所以我上了一堂课:
public class FileName
{
private string _value;
public FileName(string pValue)
{
_value = pValue;
}
public string Value
{
get
{
return _value;
}
set { _value = value; }
}
}
Run Code Online (Sandbox Code Playgroud)
这是容器类,它只是一个具有字符串值的属性.我现在想要的是当我将其数据源绑定到List时,该字符串将出现在datagridview中.
我也有这个方法,BindGrid(),我想填充datagridview.这里是:
private void BindGrid()
{
gvFilesOnServer.AutoGenerateColumns = false;
//create the column programatically
DataGridViewTextBoxColumn colFileName = new DataGridViewTextBoxColumn();
DataGridViewCell cell = new DataGridViewTextBoxCell();
colFileName.CellTemplate = cell; colFileName.Name = "Value";
colFileName.HeaderText = "File Name";
colFileName.ValueType = typeof(FileName);
//add the column to the datagridview
gvFilesOnServer.Columns.Add(colFileName);
//fill the string …Run Code Online (Sandbox Code Playgroud) 我想将文本块文本绑定到静态类的属性.只要静态类的属性值发生更改,它就应该反映到另一个窗口或自定义控件上的文本块.
我创建了一个类似于此的Person:
public class Person
{
public enum GenderType
{
Female,
Male
}
public string Name
{
get; set;
}
public GenderType? Gender
{
get; set;
}
}
Run Code Online (Sandbox Code Playgroud)
接下来,我创建了将呈现Person类型对象的数据模板.
这是XAML代码:
<DataTemplate
x:Key="personTemplate"
DataType="{x:Type model:Person}">
<StackPanel>
<RadioButton
Content="Female"
IsChecked="{Binding Path=Gender,
Converter={StaticResource genderConverter},
ConverterParameter=???}"/>
<RadioButton
Content="Male"
IsChecked="{Binding Path=Gender,
Converter={StaticResource genderConverter},
ConverterParameter=???}"/>
<RadioButton
Content="Not specified"
IsChecked="{Binding Path=Gender,
Converter={StaticResource genderConverter},
ConverterParameter=???}"/>
</StackPanel>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)
当然???代码中的s不起作用:)问题是我想创建一个genderConverter转换器,它将比较给定值,即与参数中提供personObject.Gender的给定Person.GenderType值相比较,true如果值匹配则返回.
我不知道如何使转换器参数通过Person.GenderType.Female,Person.GenderType.Male并且分别null对于第一,第二和第三单选按钮.
从基于的自定义控件TextBox,我Items以这种方式创建了一个名为的属性:
public class NewTextBox : TextBox
{
public ItemCollection Items { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
在XAML中使用自定义控件时,我无法绑定属性,因为它引发异常"A'Binding'只能在DependencyObject的DependencyProperty上设置."
我该如何解决这个例外?
binding ×10
wpf ×6
.net ×3
c# ×3
xaml ×2
android ×1
binding-mode ×1
callback ×1
clojure ×1
common-lisp ×1
converter ×1
datagridview ×1
events ×1
javascript ×1
lisp ×1
radio-button ×1
scope ×1
service ×1
textblock ×1
width ×1