首页 > WPF > WPF之布局–BulletDecorator

WPF之布局–BulletDecorator

内容模型:BulletDecorator 是一个 Decorator 元素,它具有两个内容属性: BulletChild Bullet 属性定义用作项目符号的 UIElement Child 属性定义以可视化方式与该项目符号对齐的 UIElement

如果 Child 对象是一个 TextBlock Bullet 始终与第一行文本对齐。如果 Child 对象不是一个 TextBlock Bullet 则与 Child 对象的中心对齐。有关 BulletDecorator 的布局的更多信息,请参见 如何:创建 BulletDecorator

下图演示 BulletDecorator 控件的示例。

3 个 BulletDecorator:CheckBox、RadioButton、TextBox

在这里也需要注意:BulletDecorator 中只能有一个Bullet节点

下面是我做的例子:

image

<Window x:Class="WpfApplication2.Window2"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window2" Height="208" Width="217">
    <WrapPanel>
        <BulletDecorator Height="25" VerticalAlignment="Top" Margin="5 10 0 0">
            <BulletDecorator.Bullet>
                <Label>姓名:</Label>
            </BulletDecorator.Bullet>
            <TextBox Width="100"></TextBox>
        </BulletDecorator>
        <BulletDecorator Height="25" VerticalAlignment="Top" Margin="5 10 0 10">
            <BulletDecorator.Bullet>
                <Label>年龄:</Label>
            </BulletDecorator.Bullet>
            <TextBox Width="100"></TextBox>
        </BulletDecorator>
        <BulletDecorator  Margin="5 10 0 0">
            <BulletDecorator.Bullet>
                <CheckBox IsChecked="True"></CheckBox>
            </BulletDecorator.Bullet>
            <TextBlock Width="100" Foreground="Red">在CheckBox之后</TextBlock>
        </BulletDecorator>
        <BulletDecorator Margin="5,10,0,0">
            <BulletDecorator.Bullet>
                <RadioButton/>
            </BulletDecorator.Bullet>
            <TextBlock
      Width="100" 
      TextWrapping="Wrap" 
      HorizontalAlignment="Left"
      Foreground ="Blue"
      Margin="5,0,0,0">
      在Radio后
            </TextBlock>
        </BulletDecorator>
    </WrapPanel>
</Window>

分类:WPF
  1. 还没有评论。
  1. No trackbacks yet.

留下评论