导出 (0) 打印
全部展开

ContentControl 类

Represents a control with a single piece of content.

命名空间: System.Windows.Controls
程序集: PresentationFramework(在 presentationframework.dll 中)
XML 命名空间:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)] 
[ContentPropertyAttribute("Content")] 
public class ContentControl : Control, IAddChild
/** @attribute LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) */ 
/** @attribute ContentPropertyAttribute("Content") */ 
public class ContentControl extends Control implements IAddChild
LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable) 
ContentPropertyAttribute("Content") 
public class ContentControl extends Control implements IAddChild
<ContentControl>
  Content
</ContentControl>

A ContentControl has a limited default style. If you want to enhance the appearance of the control, you can create a new control template. For more information, see Data Templating Overview. Another typical scenario is to use the ContentControl to show more information about an item selected in an ItemsControl control. For more information, see How to: Bind to a Collection and Display Information Based on Selection.

Content Model: ContentControl is the class from which other content controls inherit. For more information on the content model for ContentControl, see ContentControl Content Model.

The following example shows how to make a style for a ContentControl so that the control has an enhanced visual appearance.

<Style x:Key="ContentCtrl" TargetType="{x:Type ContentControl}">
      <Setter Property="Foreground" Value="Green"/>
      <Setter Property="FontSize" Value="20"/>
      <Setter Property="FontWeight" Value="Bold"/>
      <Setter Property="Template">
          <Setter.Value>
               <ControlTemplate TargetType="{x:Type ContentControl}">
                    <ContentControl ContentControl.Content="Hello"/>      
               </ControlTemplate>
          </Setter.Value>
      </Setter>   
</Style>

System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Media.Visual
         System.Windows.UIElement
           System.Windows.FrameworkElement
             System.Windows.Controls.Control
              System.Windows.Controls.ContentControl
                 派生类

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

Windows Vista、Microsoft Windows XP SP2 和 Windows Server 2003 SP1 支持 Microsoft .NET Framework 3.0。

.NET Framework

受以下版本支持:3.0

社区附加资源

添加
显示:
© 2014 Microsoft