我如何将以下代码编写为 XAML
假设我们有这段代码
        var myValue = someMethodeReturn(); // the return will fit
        // could also be an other nonbindable property
        var myTextBlock = new TextBlock();
        myTextBlock.Inlines = myValue;
你将如何转换
       var myValue = someMethodeReturn(); 
和
myTextBlock.Inlines = myValue;
仅作为XAML
第一部分肯定看起来像,第二部分看起来像  ???={Binding myProperty}
,<TextBlock.Inlines><???/></TextBlock.Inlines>
 但???会是什么样子?
视觉结果应该是这样的(如果你执行你的解决方案)
    <TextBlock  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="LightGray" TextWrapping="WrapWithOverflow" >
        <TextBlock.Inlines>
            <Run>meine sehr sehr sehr sehr sehr sehr sehr sehr sehr sehr sehr  lange run 1</Run>
            <Run Foreground="Green" FontFamily='Palatino Linotype' Typography.Variants='Superscript'>meine run2</Run>
            <Run>meine sehr sehr sehr sehr sehr sehr sehr sehr sehr sehr sehr  lange run</Run>
            <Run Foreground="LimeGreen" Background="Yellow">meine run3</Run>
            <Run>meine sehr sehr sehr sehr sehr sehr sehr sehr sehr sehr sehr  lange run</Run>
        </TextBlock.Inlines>
    </TextBlock>
我在 TagesItemsControl之间进行了测试,TextBlock.Inlines但它默认返回 TextBlocks,我无法设置Run或InLine作为ItemTemplate
我想我只需要一个Control返回 aList<Inline>但我不知道哪个Control能够做到这一点
任何建议,将不胜感激
我尝试了以下想法
第一的
<TextBlock  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="LightGray" TextWrapping="WrapWithOverflow" >
    <TextBlock.Inlines>
        <ContentControl Content="{Binding myBinding}"/>
    </TextBlock.Inlines>
</TextBlock>
仅返回“(Auflistung)”作为文本
第二
    <TextBlock  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="LightGray" TextWrapping="WrapWithOverflow" >
        <TextBlock.Inlines>
            <ItemsControl ItemsSource="{Binding myBinding}"/>
        </TextBlock.Inlines>
    </TextBlock>
返回一个包含在 a 中的 TextBox 列表ContenPresenter

