<legend id='3uCX4'><style id='3uCX4'><dir id='3uCX4'><q id='3uCX4'></q></dir></style></legend>
  • <small id='3uCX4'></small><noframes id='3uCX4'>

    <tfoot id='3uCX4'></tfoot>
    • <bdo id='3uCX4'></bdo><ul id='3uCX4'></ul>
    <i id='3uCX4'><tr id='3uCX4'><dt id='3uCX4'><q id='3uCX4'><span id='3uCX4'><b id='3uCX4'><form id='3uCX4'><ins id='3uCX4'></ins><ul id='3uCX4'></ul><sub id='3uCX4'></sub></form><legend id='3uCX4'></legend><bdo id='3uCX4'><pre id='3uCX4'><center id='3uCX4'></center></pre></bdo></b><th id='3uCX4'></th></span></q></dt></tr></i><div id='3uCX4'><tfoot id='3uCX4'></tfoot><dl id='3uCX4'><fieldset id='3uCX4'></fieldset></dl></div>

        WPF列表框项目不自动换行

        WPF listbox item not wordwrapping(WPF列表框项目不自动换行)

        <small id='Xyh1j'></small><noframes id='Xyh1j'>

      1. <i id='Xyh1j'><tr id='Xyh1j'><dt id='Xyh1j'><q id='Xyh1j'><span id='Xyh1j'><b id='Xyh1j'><form id='Xyh1j'><ins id='Xyh1j'></ins><ul id='Xyh1j'></ul><sub id='Xyh1j'></sub></form><legend id='Xyh1j'></legend><bdo id='Xyh1j'><pre id='Xyh1j'><center id='Xyh1j'></center></pre></bdo></b><th id='Xyh1j'></th></span></q></dt></tr></i><div id='Xyh1j'><tfoot id='Xyh1j'></tfoot><dl id='Xyh1j'><fieldset id='Xyh1j'></fieldset></dl></div>

        <legend id='Xyh1j'><style id='Xyh1j'><dir id='Xyh1j'><q id='Xyh1j'></q></dir></style></legend>
          <tbody id='Xyh1j'></tbody>

        1. <tfoot id='Xyh1j'></tfoot>
          • <bdo id='Xyh1j'></bdo><ul id='Xyh1j'></ul>

                  本文介绍了WPF列表框项目不自动换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我的 ListBox 有一个描述字段,其中可能会很长.而不是有一个水平滚动条,我想把它换行.如果我设置 MaxWidth 就可以了,但是由于 ListBox 改变了大小,我不想硬编码这个值.

                  My ListBox has, amongst other things a description field in it which can be quite long. Instead of having a horizontal scroll bar I want to word wrap it. It works if I set the MaxWidth but since the ListBox changes size I don't want to hard code the value.

                  最好的方法是什么?

                  描述在 TextBlock 中.

                  简化的 XAML(删除了不必要的东西,仍然显示问题:

                  Simplified XAML (Removed unnessesary stuff, still shows problem:

                           <ListBox BorderThickness="0" Padding="5" Name="lstTasks">
                              <ListBox.ItemsSource>
                                  <Binding Source="{StaticResource dataTasks}"/>
                              </ListBox.ItemsSource>
                  
                              <ListBox.ItemTemplate>
                                  <DataTemplate>
                                      <Grid>
                                          <TextBlock Text="{Binding Path=RequestDescription}" TextTrimming="WordEllipsis" TextWrapping="Wrap" Height="60" />
                                      </Grid>
                                  </DataTemplate>
                              </ListBox.ItemTemplate>
                          </ListBox>
                  

                  推荐答案

                  尝试强制 ListBoxItems 的宽度为 ListBox 的宽度:

                  Try forcing the width of your ListBoxItems to be the width of the ListBox:

                  <ListBox
                       Name="lstTasks"
                       BorderThickness="0"
                       Padding="5"
                       HorizontalContentAlignment="Stretch">
                  

                  您也可以尝试禁用水平滚动:

                  Also you might try disabling horizontal scrolling:

                  <ListBox
                       ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                       ...>
                  

                  这篇关于WPF列表框项目不自动换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Populate ListBox with a IEnumrable on another thread (winforms)(在另一个线程(winforms)上使用 IEnumrable 填充 ListBox)
                  listbox selected item give me quot; System.Data.DataRowViewquot; , C# winforms(列表框选择的项目给我quot;System.Data.DataRowView, C# Winforms)
                  Cannot remove items from ListBox(无法从列表框中删除项目)
                  Preventing ListBox scrolling to top when updated(更新时防止列表框滚动到顶部)
                  Deselection on a WPF listbox with extended selection mode(具有扩展选择模式的 WPF 列表框上的取消选择)
                  How do I get at the listbox item#39;s quot;keyquot; in c# winforms app?(如何获取列表框项目的“键?在 c# winforms 应用程序中?)
                  <i id='uOxWB'><tr id='uOxWB'><dt id='uOxWB'><q id='uOxWB'><span id='uOxWB'><b id='uOxWB'><form id='uOxWB'><ins id='uOxWB'></ins><ul id='uOxWB'></ul><sub id='uOxWB'></sub></form><legend id='uOxWB'></legend><bdo id='uOxWB'><pre id='uOxWB'><center id='uOxWB'></center></pre></bdo></b><th id='uOxWB'></th></span></q></dt></tr></i><div id='uOxWB'><tfoot id='uOxWB'></tfoot><dl id='uOxWB'><fieldset id='uOxWB'></fieldset></dl></div>
                    • <legend id='uOxWB'><style id='uOxWB'><dir id='uOxWB'><q id='uOxWB'></q></dir></style></legend>
                    • <small id='uOxWB'></small><noframes id='uOxWB'>

                        <bdo id='uOxWB'></bdo><ul id='uOxWB'></ul>
                          <tfoot id='uOxWB'></tfoot>

                              <tbody id='uOxWB'></tbody>