InlineUIContainer.Child プロパティ

定義

UIElement によってホストされる InlineUIContainer を取得または設定します。Gets or sets the UIElement hosted by the InlineUIContainer.

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 によってホストされる InlineUIContainerThe UIElement hosted by the InlineUIContainer.

次の例は、要素を使用InlineUIContainerしてフロー UIElementコンテンツ内の要素をホストする方法を示しています。The following example shows how to use the InlineUIContainer elements to host UIElement elements within flow content.

<FlowDocument ColumnWidth="400">
  <Paragraph Background="GhostWhite">
    <Run>
      A UIElement element may be embedded directly in flow content
      by enclosing it in an InlineUIContainer element.
    </Run>
    <LineBreak/>
    <LineBreak/>
    <InlineUIContainer>
      <Button>Click me!</Button>
    </InlineUIContainer>
    <LineBreak/>
    <LineBreak/>
    <Run>
      The InlineUIContainer element may host no more than one top-level
      UIElement.  However, other UIElements may be nested within the
      UIElement contained by an InlineUIContainer element.  For example,
      a StackPanel can be used to host multiple UIElement elements within
      an InlineUIContainer element.
    </Run>
    <InlineUIContainer>
      <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>
    </InlineUIContainer>
  </Paragraph>
</FlowDocument>

この例の表示結果を次の図に示します。The following figure shows how this example renders.

![スクリーン]Flow(~/add/media/inlineuicontainer.png "スクリーンショットに埋め込まれた UIElement 要素:Flow に埋め込まれた UIElement 要素")Screenshot: UIElement elements embedded in flow

次の例は、プログラムでChildプロパティを使用する方法を示しています。The following example shows how to use the Child property programmatically.

Paragraph parx = new Paragraph();
Run run1 = new Run(" Text to precede the button... ");
Run run2 = new Run(" Text to follow the button... ");

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

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

// Add the text runs and UI container to the paragraph, in order.
parx.Inlines.Add(run1);
parx.Inlines.Add(uiCont);
parx.Inlines.Add(run2);
Dim parx As New Paragraph()
Dim run1 As New Run(" Text to precede the button... ")
Dim run2 As New Run(" Text to follow the button... ")

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

' Create a new InlineUIContainer, and assign the button 
' as the UI container's child.
Dim uiCont As New InlineUIContainer()
uiCont.Child = buttonx

' Add the text runs and UI container to the paragraph, in order.
parx.Inlines.Add(run1)
parx.Inlines.Add(uiCont)
parx.Inlines.Add(run2)

注釈

InlineUIContainer 、1つUIElementの子を直接ホストすることはできません。An InlineUIContainer may directly host no more than one UIElement child. ただし、によってInlineUIContainerホストされる子要素は、独自のの子をホストできます。However, the child element hosted by an InlineUIContainer may host children of its own.

XAMLXAMLは、をUIElementにラップInlineUIContainer することUIElementは、プロパティの値としてを設定することと同じです。ChildIn XAMLXAML, wrapping a UIElement in an InlineUIContainer is equivalent to setting that UIElement as the value of the Child property.

適用対象