Cette documentation est archivée et n’est pas conservée.

BulletDecorator, classe

Represents a layout control that aligns a "bullet" and another visual object.

Espace de noms: System.Windows.Controls.Primitives
Assembly : PresentationFramework (dans presentationframework.dll)
Espace de noms XML :  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public class BulletDecorator : Decorator
public class BulletDecorator extends Decorator
public class BulletDecorator extends Decorator
<BulletDecorator>
  Child
</BulletDecorator>

Content Model: BulletDecorator is a Decorator element, and has two content properties: Bullet and Child. The Bullet property defines the UIElement to use as a bullet. The Child property defines a UIElement that visually aligns with the bullet.

A BulletDecorator control consists of a Bullet, such as an Image, CheckBox, or RadioButton, followed by a UIElementChild object, such as a text string. The BulletDecorator aligns the Bullet with the Child and automatically updates the alignment between them if their properties change.

A Bullet always aligns with the first line of text when the Child object is a text object. If the Child object is not a text object, the Bullet aligns to the center of the Child object. For more information about layout of a BulletDecorator, see How to: Create a BulletDecorator.

If the Bullet is a CheckBox or RadioButton, the user can click the Bullet or the Child to toggle the state of the CheckBox or RadioButton.

A BulletDecorator can only contain one element, in addition to the Bullet element. If a BulletDecorator contains more than one element and a Bullet, an InvalidOperationException occurs at run time.

The following illustration shows examples of BulletDecorator controls.

BulletDecorator styles

The following examples show how to define a BulletDecorator control.

<BulletDecorator  Grid.Row="1" Grid.Column="0" Margin="0,5,0,0"
                  VerticalAlignment="Center" Background="Yellow">
  <BulletDecorator.Bullet>
    <Image Source="images\apple.jpg"/>
  </BulletDecorator.Bullet>
  <TextBlock
    Width="100" 
    TextWrapping="Wrap" 
    HorizontalAlignment="Left"
    Foreground ="Purple">
    A Simple BulletDecorator
  </TextBlock>
</BulletDecorator>

BulletDecorator myBulletDecorator = new BulletDecorator();
Image myImage = new Image();
BitmapImage myBitmapImage = new BitmapImage();
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@"pack://application:,,/images/apple.jpg");
myBitmapImage.EndInit();
myImage.Source = myBitmapImage;
myImage.Width = 10;
myBulletDecorator.Bullet = myImage;
myBulletDecorator.Margin = new Thickness(0, 10, 0, 0);
myBulletDecorator.VerticalAlignment = VerticalAlignment.Center;
myBulletDecorator.Background = Brushes.Yellow;
TextBlock myTextBlock = new TextBlock();
myTextBlock.Text = "This BulletDecorator created by using code";
myTextBlock.TextWrapping = TextWrapping.Wrap;
myTextBlock.HorizontalAlignment = HorizontalAlignment.Left;
myTextBlock.Width = 100;
myTextBlock.Foreground = Brushes.Purple;
myBulletDecorator.Child = myTextBlock;

System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Media.Visual
         System.Windows.UIElement
           System.Windows.FrameworkElement
             System.Windows.Controls.Decorator
              System.Windows.Controls.Primitives.BulletDecorator

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
Afficher: