2012-11-10 53 views
0

爲什麼我無法在我的類中創建簡單的WPF字符串數據綁定?字符串綁定錯誤

Error: Overload resolution failed because no accessible 'New' accepts this number of arguments.

我跟隨this example in MSDN

Dim s As String = "Test string" 
Dim b As New Binding("Description of bind") 
b.Mode = BindingMode.OneTime 
b.Source = s 
+0

您是否知道應該將綁定的'Path'傳遞給構造函數,而不是綁定的任何文本描述? – stakx

+0

謝謝你的評論,但你的意思是?你能舉個例子嗎? – ElektroStudios

+0

我在向你指出'''bind的描述''很可能不是['Binding'構造函數]的有效參數(http://msdn.microsoft.com/zh-cn/library/ms597578.aspx )你打電話。構造函數不包含任何*文本(人類語言)對綁定本質的描述;它期望一個綁定的'Path',它具有你必須遵守的特定語法;例如'「/ Offices/ManagerName」'或'「ShoppingCart.Order」'。 [詳情請參閱'Binding.Path'的文檔。](http://msdn.microsoft.com/en-us/library/system.windows.data.binding.path.aspx) – stakx

回答

1

我不熟悉用VB,但它會出現該行應爲:

Dim b As New Binding() 
b.Path = New PropertyPath("Description of bind") 

我提到這link

+0

謝謝你,但我已經嘗試過你的例子不成功 – ElektroStudios