【问题标题】:Blocks to UIElement conversion块到 UIElement 的转换
【发布时间】:2009-10-25 15:51:47
【问题描述】:

是否可以将System.Windows.Documents.Block 转换为System.Windows.UIElement

我需要这个,因为我想将创建的块添加到固定文档中。有没有其他办法?

【问题讨论】:

    标签: flowdocument uielement fixeddocument


    【解决方案1】:

    如果有人仍然需要知道这一点,这很容易。

    只需使用 BlockUIElement 来包含 UIElement。

    例如,如果您要将 Border 元素附加到表格的单元格:

    TableCell 单元格 = new TableCell(new Border()); //不会工作!

    TableCell cell = new TableCell(new BlockUIContainer(new Border()));好的!

    【讨论】:

    • 这不是和OP想要的相反吗?你di UIElement -> Block,他想要Block -> UIElement
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多