同様のニーズがあり、Andy's answer の行に沿って解決しました... BindableTextBlock を作成しました。
class BindableTextBlock : TextBlock
{
public Inline BoundInline
{
get { return (Inline)GetValue(BoundInlineProperty); }
set { SetValue(BoundInlineProperty, value); }
}
public static readonly DependencyProperty BoundInlineProperty =
DependencyProperty.Register("BoundInline", typeof(Inline), typeof(BindableTextBlock),
new UIPropertyMetadata((PropertyChangedCallback)((d, e) => { ((BindableTextBlock)d).Inlines.Clear(); ((BindableTextBlock)d).Inlines.Add(e.NewValue as Inline); })));
}
次に、XAML で BoundInline 依存関係プロパティにバインドできます。
<DataTemplate x:Key="TempTemplate">
<t:BindableTextBlock TextWrapping="Wrap" BoundInline="{Binding Path=TextInlines}" Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2" />
</DataTemplate>
これの 1 つの欠点は、単一のルート インラインのみをテキスト ブロックにバインドできることです。これは、コンテンツがすべてトップレベルのスパンにラップされているため、私の状況ではうまく機能しました。