如何在ListViewItem中包装Text?

时间:2010-08-04 08:52:29

标签: wpf listboxitem textwrapping

WPF ListBoxItem如何将文本换行? My Item容器样式如下所示:

        <Style x:Key="GroupListBoxItemStyle"
           TargetType="ListBoxItem">
        <Setter Property="OverridesDefaultStyle"
                Value="True" />
        <Setter Property="FocusVisualStyle"
                Value="{x:Null}" />
        <Setter Property="FontSize"
                Value="11" />
        <Setter Property="FontWeight"
                Value="Bold" />
        <Setter Property="Width"
                Value="95" />
        <Setter Property="HorizontalAlignment"
                Value="Center" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="ListBoxItem">
                    <SlidingBar:SlidingBarRadioButton GroupName="PermissionsRadioButtonGroup"
                                                      IsChecked="{Binding Path=IsSelected,RelativeSource={RelativeSource TemplatedParent},BindsDirectlyToSource=True,Mode=TwoWay}"
                                                      Text="{Binding Converter={StaticResource resourceStringToResourceConverter}}"
                                                      ImageSource="{Binding Converter={StaticResource PermissionTypeToImageConverter}}" 
                                                      Margin="1"                                                          
                                                      />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

1 个答案:

答案 0 :(得分:2)

确保将以下属性设置为ListBox / ListView:

<强> Horizo​​ntalContentAlignment = “拉伸”

<强> ScrollViewer.Horizo​​ntalScrollBarVisibility = “禁用”