Exporter (0) Imprimer
Développer tout

ContentControl, classe

Represents a control with a single piece of content.

Espace de noms: System.Windows.Controls
Assembly : PresentationFramework (dans presentationframework.dll)
Espace de noms 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
                 Classes dérivées

Les membres statiques publics (Shared en Visual Basic) de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Microsoft .NET Framework 3.0 est pris en charge sur Windows Vista, Microsoft Windows XP SP2 et Windows Server 2003 SP1.

.NET Framework

Prise en charge dans : 3.0

Ajouts de la communauté

AJOUTER
Microsoft réalise une enquête en ligne pour recueillir votre opinion sur le site Web de MSDN. Si vous choisissez d’y participer, cette enquête en ligne vous sera présentée lorsque vous quitterez le site Web de MSDN.

Si vous souhaitez y participer,
Afficher:
© 2014 Microsoft