2010-08-05 105 views
0

這看起來很基本,但我想顯示當前存在於DataContext中的一些CLR對象的表示。WPF:顯示模板對象

我已經設置了DataTemplates,我希望它們看起來如何,我只是想將它們放到視覺空間中。

我想這一點,但它並不能幫助:

  <StackPanel> 
       <Binding Path="CalibrationA" /> 
       <Binding Path="CalibrationB" /> 
      </StackPanel> 

模板,以供參考(其傳感器校準):

   <DataTemplate DataType="{x:Type ns:CalibrationTable}"> 
        <StackPanel> 
         <TextBlock Text="{Binding TableName}" /> 
         <ListBox ItemsSource="{Binding}" /> 
         <StackPanel Orientation="Horizontal"> 
          <TextBlock Text="{Binding KeyName}" /> 
          <TextBox Width="50"></TextBox> 
          <TextBlock Text="{Binding ValueName}" /> 
          <TextBox Width="50"></TextBox> 
          <Button Content="Add" /> 
         </StackPanel> 
        </StackPanel> 
       </DataTemplate> 

有什麼建議?

回答

1

你要找的類是ContentPresenter:

<StackPanel> 
    <ContentPresenter Content={Binding Foobar1} /> 
    <ContentPresenter Content={Binding Foobar1} /> 
<StackPanel> 
+0

完美,謝謝! – rrhartjr 2010-08-05 17:22:03