BlockUIContainer.Child Свойство

Определение

Получает или задает объект UIElement, размещенный в контейнере BlockUIContainer.Gets or sets the UIElement hosted by the BlockUIContainer.

public:
 property System::Windows::UIElement ^ Child { System::Windows::UIElement ^ get(); void set(System::Windows::UIElement ^ value); };
public System.Windows.UIElement Child { get; set; }
member this.Child : System.Windows.UIElement with get, set
Public Property Child As UIElement

Значение свойства

Объект UIElement, размещенный в контейнере BlockUIContainer.The UIElement hosted by the BlockUIContainer.

Примеры

В следующем примере показано, как использовать BlockUIContainer элементы для размещения UIElement элементов в содержимом нефиксированного формата.The following example shows how to use the BlockUIContainer elements to host UIElement elements within flow content.

<FlowDocument ColumnWidth="400">
  <Section Background="GhostWhite">
    <Paragraph>
      A UIElement element may be embedded directly in flow content
      by enclosing it in a BlockUIContainer element.
    </Paragraph>
    <BlockUIContainer>
      <Button>Click me!</Button>
    </BlockUIContainer>
    <Paragraph>
      The BlockUIContainer element may host no more than one top-level
      UIElement.  However, other UIElements may be nested within the
      UIElement contained by an BlockUIContainer element.  For example,
      a StackPanel can be used to host multiple UIElement elements within
      a BlockUIContainer element.
    </Paragraph>
    <BlockUIContainer>
      <StackPanel>
        <Label Foreground="Blue">Choose a value:</Label>
        <ComboBox>
          <ComboBoxItem IsSelected="True">a</ComboBoxItem>
          <ComboBoxItem>b</ComboBoxItem>
          <ComboBoxItem>c</ComboBoxItem>
        </ComboBox>
        <Label Foreground ="Red">Choose a value:</Label>
        <StackPanel>
          <RadioButton>x</RadioButton>
          <RadioButton>y</RadioButton>
          <RadioButton>z</RadioButton>
        </StackPanel>
        <Label>Enter a value:</Label>
        <TextBox>
          A text editor embedded in flow content.
        </TextBox>
      </StackPanel>
    </BlockUIContainer>
  </Section>
</FlowDocument>

На следующем рисунке показана отрисовка этого примера.The following figure shows how this example renders.

![Снимок экрана Снимок экрана, внедренный]в поток содержимого(~/add/media/blockuicontainer.png "нефиксированного формата: UIElement, внедренный в нефиксированное содержимое")Screenshot: UIElement embedded in flow content

В следующем примере показано, как использовать Child свойство программным способом.The following example shows how to use the Child property programmatically.

Section secx = new Section();
Paragraph par1 = new Paragraph(new Run(" Text to precede the button... "));
Paragraph par2 = new Paragraph(new Run(" Text to follow the button... "));

// Create a new button to be hosted in the section.
Button buttonx = new Button();
buttonx.Content = "Click me!";

// Create a new BlockUIContainer, and assign the button 
// as the UI container's child.
BlockUIContainer uiCont = new BlockUIContainer();
uiCont.Child = buttonx;

// Add the text runs and UI container to the paragraph, in order.
secx.Blocks.Add(par1);
secx.Blocks.Add(uiCont);
secx.Blocks.Add(par2);
Dim secx As New Section()
Dim par1 As New Paragraph(New Run(" Text to precede the button... "))
Dim par2 As New Paragraph(New Run(" Text to follow the button... "))

' Create a new button to be hosted in the section.
Dim buttonx2 As New Button()
buttonx2.Content = "Click me!"

' Create a new BlockUIContainer, and assign the button 
' as the UI container's child.
Dim uiCont2 As New BlockUIContainer()
uiCont2.Child = buttonx2

' Add the text runs and UI container to the paragraph, in order.
secx.Blocks.Add(par1)
secx.Blocks.Add(uiCont2)
secx.Blocks.Add(par2)

Комментарии

В BlockUIContainer может размещаться не более одного UIElement дочернего элемента.An BlockUIContainer may directly host no more than one UIElement child. Однако дочерний элемент, размещенный BlockUIContainer в, может размещать собственные дочерние элементы.However, the child element hosted by an BlockUIContainer may host children of its own.

В XAMLXAML UIElement Child заключение в оболочку в BlockUIContainer эквивалентно заданию значения свойства. UIElementIn XAMLXAML, wrapping a UIElement in an BlockUIContainer is equivalent to setting that UIElement as the value of the Child property.

Применяется к