【发布时间】:2009-08-15 22:51:57
【问题描述】:
我想对以下问题提出建议:我想将Button 嵌入到文本流中,但是当我将Button 和Label(或TextBlock)嵌入到WrapPanel 中时,我得到了第一个数字:
alt text 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>
【问题讨论】:
标签: wpf button flowdocument word-wrap wrappanel