我想对以下问题提出建议:我想将 a 嵌入Button
到文本流中,但是当我将 a Button
and Label
(or TextBlock
)嵌入到 中时WrapPanel
,我得到了第一个数字:
替代文字 http://sklad.tomaskafka.com/files/wpf-wrappanel-problem.png
我认为解决方案之一可能是FlowDocument
,但我觉得这对于像这样简单的控件(可以在数百个实例中使用)来说太重了。您对如何实现这一点还有其他想法吗?谢谢!
编辑:一种解决方案可能如下(我不知道可以将更多的东西放入TextBlock
),但我会失去绑定的能力(我需要):
<TextBlock TextWrapping="Wrap">
<Span>
<Button x:Name="MyButton" Command="{Binding Path=MyCommand}" Content="+" />
<Run x:Name="MyLabel" Text="{Binding Path=Subject}" />
<!--
Problem: binding makes following error:
A 'Binding' cannot be set on the 'Text' property of type 'Run'.
A 'Binding' can only be set on a DependencyProperty of a DependencyObject.
-->
</Span>
</TextBlock>