2016-02-25 88 views
0

作爲WPF的相對新手,我很努力地看到爲什麼我在以下場景中遇到綁定錯誤。MultiBinding Converter上的綁定錯誤

我有以下XAML

<TextBlock.Text> 
    <MultiBinding Converter="{StaticResource CardinalityConverter}"> 
     <Binding/> 
     <Binding Path="ed.Min" /> 
     <Binding Path="ed.Max" /> 
    </MultiBinding> 
</TextBlock.Text> 

的綁定錯誤我得到的是如下

System.Windows.Data Warning: 40 : BindingExpression path error: 'ed' property not found on 'object' ''SDNode' (HashCode=2343823)'. BindingExpression:Path=ed.Min; DataItem='SDNode' (HashCode=2343823); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') 
System.Windows.Data Warning: 40 : BindingExpression path error: 'ed' property not found on 'object' ''SDNode' (HashCode=2343823)'. BindingExpression:Path=ed.Max; DataItem='SDNode' (HashCode=2343823); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String') 

如果我把一個斷點在「CardinalityConverter」則看到下面,你可以看到值(1)和值(2)未設置。

enter image description here

如果我擴大值(0),那麼以下是看到

enter image description here

'編' 是清楚地看到,爲什麼不綁定不認識到這一點?

回答

0

字段不能是Binding的源或目標,只有正常的CLR屬性或依賴項屬性才能參與WPF的綁定系統。

試試你的綁定設置爲以下:

<Binding Path="ED.Min" /> 
<Binding Path="ED.Max" /> 

如果我沒有記錯的話,你所提供的,你已經有一個名爲ED暴露的公共屬性,所以應結合與工作的形象判斷。

場看起來是這樣的:

public class SomeClass 
{ 
    public string SomeField = "Some Value"; 
} 

雖然性質是這樣的:

public class SomeClass 
{ 
    public string SomeProperty { get; set; } 
}