WPF:显示模板对象

问题描述:

这看起来很基本,但我想显示当前存在于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> 

有什么建议?

你要找的类是ContentPresenter:

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

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