0
我试图在运行时创建带有自动换行的复选框。与自动换行复选框的XAML看起来是这样的:在运行时创建TextBlock
<CheckBox Width="140" Height="35">
<ContentControl>
<TextBlock TextWrapping="Wrap">This is a long text with word wrap</TextBlock>
</ContentControl>
</CheckBox>
现在我要创建这个用XAML代码,但我不知道如何得到它的工作。我能够创建复选框并将其添加到现有的WrapPanel,但textBlock控件没有内容属性。我如何将内容添加到textBlock,以及如何将两者(contentControl和textBlock)添加到复选框?
For intIndex = 0 To m_aryActions.Length - 1
Dim textBlock As TextBlock = New TextBlock
Dim contentControl As ContentControl = New ContentControl
Dim checkBox As CheckBox = New CheckBox
textBlock.TextWrapping = TextWrapping.Wrap
contentControl.Content = textBlock
With checkBox
.Width = 140
.Height = 25
.Name = "CheckBox" & intIndex
End With
WrapPanel.Children.Add(checkBox)
Next
谢谢, 彼得
没人的想法?太容易或经常被问到?我已经搜索,但没有找到解决方案。太难了?我不相信。 – user1954535