2011-07-22 75 views
0

在我的XAML我有兩個自定義組件:HOWTO一個XAML對象分配給一個屬性(.NET35,XAML2006)

<gui:CustomerBrowser x:Name="browser" CustomerDetailView="???" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" /> 
<gui:CustomerDetails x:Name="details" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" /> 

我喜歡第二組分分配到第一部分,但我不的屬性沒辦法。 CustomerDetailView屬性需要包含什麼?

CustomerDetailView的類型是接口ICustomerView,其他組件CustomerDetails實施。使用:VS2010,.NET3.5,XAML2006。

回答

3

編輯:我非常期待WPF 3.5中使用,你可以只嘗試一個正常的約束力在這種情況下:

CustomerDetailsView="{Binding ElementName=details}" 

(在.NET 4中,你可以使用x:Reference :)

CustomerDetailsView="{x:Reference details}" 
+0

'x:Reference'需要XAML2009/.NET4。但我必須堅持.NET 3.5(VS 2010)。 – ZoolWay

+0

如果您使用的是最新版本以外的版本,您應該在標籤中清楚地說明(可能還有問題)。您是否嘗試過綁定(請參閱更新後的答案)。 –

+0

沒有XAML2006標籤,但我在問題中添加了信息。 – ZoolWay

相關問題