我需要为CheckBox设置TextWrapping,就像TextBlock一样,但CheckBox没有TextWrapping属性。如何为CheckBox配置TextWrapping?
<Grid>
<ListBox>
<TextBlock Text="{Binding LocalizedResources.CleanCity, Source={StaticResource LocalizedStrings}}" Foreground="Black" FontSize="32" FontWeight="Bold"/>
<CheckBox x:Name="c1" Foreground="{StaticResource CustomApplicationTextBrush}" Background="#BFC2E2FD"/>
<CheckBox x:Name="c2" Foreground="{StaticResource CustomApplicationTextBrush}" Background="#BFC2E2FD"/>
<CheckBox x:Name="c3" Foreground="{StaticResource CustomApplicationTextBrush}" Background="#BFC2E2FD"/>
<CheckBox x:Name="c4" Foreground="{StaticResource CustomApplicationTextBrush}" Background="#BFC2E2FD"/>
<CheckBox x:Name="c5" Foreground="{StaticResource CustomApplicationTextBrush}" Background="#BFC2E2FD"/>
<TextBlock Text="{Binding LocalizedResources.SafeCity, Source={StaticResource LocalizedStrings}}" Foreground="Black" FontSize="32" FontWeight="Bold"/>
<CheckBox x:Name="c6" Foreground="{StaticResource CustomApplicationTextBrush}" Background="#BFC2E2FD"/>
<TextBlock Text="{Binding LocalizedResources.ComfortableCity, Source={StaticResource LocalizedStrings}}" Foreground="Black" FontSize="32" FontWeight="Bold"/>
<CheckBox x:Name="c7" Foreground="{StaticResource CustomApplicationTextBrush}" Background="#BFC2E2FD"/>
<CheckBox x:Name="c8" Foreground="{StaticResource CustomApplicationTextBrush}" Background="#BFC2E2FD"/>
<CheckBox x:Name="c9" Foreground="{StaticResource CustomApplicationTextBrush}" Background="#BFC2E2FD"/>
</ListBox>
</Grid>
谢谢!
答案 0 :(得分:0)
复选框也可以这样声明
<CheckBox>
<TextBlock>
Hi
</TextBlock>
</CheckBox>
现在textblock支持textwrapping:)
编辑
<CheckBox>
<CheckBox.Content>
<TextBlock TextWrapping="Wrap" Width="100">
Hi fkffk kffk f fkfkf fk kfhkf fkf kf fkfk
</TextBlock>
</CheckBox.Content>
</CheckBox>
以上编辑可以在点击文本块时检查取消选中。
从后面的代码设置文本
(yourcheckbox.Content as Textblock).Text="Hi world!";
答案 1 :(得分:0)
您可以随时在复选框内添加文本块。
<CheckBox>
<TextBlock Width="250" TextWrapping="Wrap">
Write your text here and wrap it whenever you want..!!
</TextBlock>
</CheckBox>
注意:当您单击文本时,这将不允许您选中/取消选中框。
答案 2 :(得分:0)
您可以在css文件中使用float: left;
您可以参考此JSfiddle链接(http://jsfiddle.net/davidThomas/9s8Db/10/)。这肯定会帮助你..!