2009-08-21 109 views
0

我正在寫我自己的UserControl,它在ListBox中顯示數據。我想實現類似於「DisplayMemberPath」之類的屬性。在我的例子中,它是「EditableMemberPath」,它應該確定哪個成員將顯示在文本框中。但是,在綁定上使用綁定不起作用。我該如何實現一個綁定路徑,該綁定路徑被另一個綁定綁定?

<ListBox ItemsSource="{Binding Path=Items, ElementName=me}" 
     SelectedItem="{Binding Path=SelectedItem, ElementName=me}"> 
    <ListBox.ItemTemplate> 
     <DataTemplate> 
      <StackPanel> 
       <Image Source="{Binding Converter={Binding Path=ItemToImageConverter, ElementName=me}}" /> 

       <TextBlock Text="{Binding Path={Binding Path=EditableMemberPath, ElementName=me}}" /> 
      </StackPanel> 
     </DataTemplate> 
    </ListBox.ItemTemplate> 
</ListBox> 

你能幫我找到一個合適的解決方案嗎?

問候
奧利弗Hanappi

+1

我已經張貼在這裏回答了這個問題代碼:http://stackoverflow.com/questions/777991/how-do-i-bind -the結合路徑屬性到底層數據/ 778146#778146 – 2009-08-21 11:21:00

回答

1

你不能這樣做,直接在XAML(至少不與內置類):一個Binding不是DependencyObject,所以你不能綁定它的屬性。

但是由馬丁·哈里斯提到的職位看起來很有希望...