语言

InlineUIContainer 类

定义

提供一个内联内容元素,使 UIElement 类型能够嵌入 到 RichTextBlock 的内容中。

public ref class InlineUIContainer sealed : Inline
/// [Microsoft.UI.Xaml.Markup.ContentProperty(Name="Child")]
/// [Windows.Foundation.Metadata.Activatable(65536, "Microsoft.UI.Xaml.WinUIContract")]
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.UI.Xaml.WinUIContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class InlineUIContainer final : Inline
[Microsoft.UI.Xaml.Markup.ContentProperty(Name="Child")]
[Windows.Foundation.Metadata.Activatable(65536, "Microsoft.UI.Xaml.WinUIContract")]
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.UI.Xaml.WinUIContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class InlineUIContainer : Inline
Public NotInheritable Class InlineUIContainer
Inherits Inline
<InlineUIContainer .../>
-or-
<InlineUIContainer ...>
  singleChild
</InlineUIContainer>

继承
Object Platform::Object IInspectable DependencyObject TextElement Inline InlineUIContainer
属性

示例

下面的代码示例演示如何使用 InlineUIContainer 将图像插入 RichTextBlock 。

<RichTextBlock>
    <Paragraph>
        <Italic>This is an inline image.</Italic>

        <InlineUIContainer>
            <Image Source="Assets/SmallLogo.png" Height="30" Width="30"/>
        </InlineUIContainer>

        Mauris auctor tincidunt auctor.
    </Paragraph>
</RichTextBlock>

注解

使用 InlineUIContainer 对象的最常见方案是将图像引入文本内容。 将图像的新 Image 对象用作 InlineUIContainer 的子内容。 如果不希望图像缩放为自然图像大小,请设置图像的高度和宽度。

如果希望将多个元素内联在同一位置,请考虑将面板用作单个 InlineUIContainer 子元素,然后将多个元素置于该面板中。

如果放置在 InlineUIContainer 中,可以聚焦的控件仍显示在顶级选项卡序列中。

如果需要交互式文本,请考虑使用 Hyperlink 元素( 内联类型),而不是将 InlineUIContainer 与 按钮 或类似内容一起使用。 请参阅 链接指南。

InlineUIContainer 从 TextElement 类继承属性。 但是,这些属性中的大多数都没有任何可见效果。 最常见的情况是在 XAML 中声明 InlineUIContainer 对象元素,而不设置任何属性(可能为 x:Name 属性除外),其中单个子元素将内联为 InlineUIContainer 对象元素的内容。

在 InlineUIContainer 上设置属性,否则会影响文本元素(如 FontSize、 FontFamily)的字符行高度对呈现和外观没有影响。 内容决定了其大小和 InlineUIContainer 大小以适应它。

如果子内容(如 TextBlock.Text 或其他文本元素在嵌套 的 RichTextBlock 中)中存在其他文本,则 InlineUIContainer 父元素的文本元素属性不会继承到内容中,将忽略它们。

构造函数

名称 说明
InlineUIContainer()

初始化 InlineUIContainer 类的新实例。

属性

名称 说明
AccessKey

获取或设置此元素的访问键。

(继承自 TextElement)
AccessKeyScopeOwner

获取或设置一个源元素,该元素提供此元素的访问键范围,即使它不在源元素的可视化树中也是如此。

(继承自 TextElement)
AllowFocusOnInteraction

获取或设置一个值,该值指示当用户与其交互时元素是否自动获得焦点。

(继承自 TextElement)
CharacterSpacing

获取或设置字符之间的统一间距,单位为 1/1000 em。

(继承自 TextElement)
Child

获取或设置由 InlineUIContainer 托管的 UIElement。

ContentEnd

获取一个 TextPointer ,表示元素中内容的末尾。

(继承自 TextElement)
ContentStart

获取一个 TextPointer ,表示元素中内容的开头。

(继承自 TextElement)
Dispatcher

始终在 Windows 应用 SDK 应用中返回 null 。 请改用 DispatcherQueue 。

(继承自 DependencyObject)
DispatcherQueue

获取 DispatcherQueue 与此对象关联的对象。 表示 DispatcherQueue 即使代码是由非 UI 线程启动,也可以访问 DependencyObject UI 线程上的设施。

(继承自 DependencyObject)
ElementEnd

获取一个 TextPointer ,它表示元素末尾之后的位置。

(继承自 TextElement)
ElementStart

获取一个 TextPointer ,表示元素开头前的位置。

(继承自 TextElement)
ExitDisplayModeOnAccessKeyInvoked

获取或设置一个值,该值指定在调用访问密钥时是否消除访问密钥显示。

(继承自 TextElement)
FontFamily

获取或设置元素内容的首选顶级字体系列。

(继承自 TextElement)
FontSize

获取或设置元素内容的字号。

(继承自 TextElement)
FontStretch

获取或设置要选择的系列中字体的字形宽度。

(继承自 TextElement)
FontStyle

获取或设置此元素中内容的字体样式。

(继承自 TextElement)
FontWeight

获取或设置要从此元素中内容的字体系列中选择的顶级字体粗细。

(继承自 TextElement)
Foreground

获取或设置要应用于此元素中内容的 Brush 。

(继承自 TextElement)
IsAccessKeyScope

获取或设置一个值,该值指示元素是否定义其自己的访问密钥范围。

(继承自 TextElement)
IsTextScaleFactorEnabled

获取或设置是否启用自动文本放大,以反映系统文本大小设置。

(继承自 TextElement)
KeyTipHorizontalOffset

获取或设置一个值,该值指示键提示相对于文本元素的左或向右放置。

(继承自 TextElement)
KeyTipPlacementMode

获取或设置一个值,该值指示键提示相对于文本元素的位置。

(继承自 TextElement)
KeyTipVerticalOffset

获取或设置一个值,该值指示键提示相对于文本元素的向上或向下放置距离。

(继承自 TextElement)
Language

获取或设置应用于 TextElement 的本地化/全球化语言信息。

(继承自 TextElement)
Name

获取或设置对象的唯一标识。 只能从 XAML 的初始分析中设置名称。

(继承自 TextElement)
TextDecorations

获取或设置一个值,该值指示应用于文本的修饰。

(继承自 TextElement)
XamlRoot

获取或设置在其中查看此元素的 XamlRoot。

(继承自 TextElement)

方法

名称 说明
ClearValue(DependencyProperty)

清除依赖属性的本地值。

(继承自 DependencyObject)
FindName(String)

通过引用对象的 x:Name 或 Name 属性值来检索对象模型/运行时对象图中的对象。

(继承自 TextElement)
GetAnimationBaseValue(DependencyProperty)

返回为依赖属性建立的任何基值,在动画未处于活动状态的情况下,该属性将适用。

(继承自 DependencyObject)
GetValue(DependencyProperty)

从 DependencyObject 返回依赖属性的当前有效值。

(继承自 DependencyObject)
OnDisconnectVisualChildren()

重写此方法以实现从类特定的内容或子属性中删除项时布局和逻辑的行为方式。

(继承自 TextElement)
ReadLocalValue(DependencyProperty)

如果设置了本地值,则返回依赖属性的本地值。

(继承自 DependencyObject)
RegisterPropertyChangedCallback(DependencyProperty, DependencyPropertyChangedCallback)

注册一个通知函数,用于侦听此 DependencyObject 实例上对特定 DependencyProperty 所做的更改。

(继承自 DependencyObject)
SetValue(DependencyProperty, Object)

设置 DependencyObject 上的依赖属性的本地值。

(继承自 DependencyObject)
UnregisterPropertyChangedCallback(DependencyProperty, Int64)

取消以前通过调用 RegisterPropertyChangedCallback 注册的更改通知。

(继承自 DependencyObject)

事件

名称 说明
AccessKeyDisplayDismissed

当访问键序列完成以通知控件应隐藏访问密钥视觉对象时发生。

(继承自 TextElement)
AccessKeyDisplayRequested

当访问键序列启动以通知控件应显示访问键视觉对象时发生。

(继承自 TextElement)
AccessKeyInvoked

当用户完成访问密钥序列以通知元素应调用访问密钥作时发生。

(继承自 TextElement)

适用于

另请参阅