• <small id='tRzZ5'></small><noframes id='tRzZ5'>

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

        WPF 列表框空数据模板

        时间:2023-10-07

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

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

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

                  <tfoot id='VKwU8'></tfoot>
                  本文介绍了WPF 列表框空数据模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想知道人们如何处理没有项目的 ListBox 控件?例如我想绑定一个搜索结果列表,但如果没有找到结果,我想显示未找到结果".

                  I was wondering how people handle a ListBox control that has no items? e.g. I want to bind a list of search results but if no results are found i would like to display "No results found".

                  我目前解决此问题的方法是,如果结果集计数 = 0,我将隐藏列表框并显示带有未找到结果"消息的标签.理想情况下,我想要 ASP .NET datagrid EmptyTemplate 解决方案.

                  The way i currently tackle this is that i hide the listbox if the result set count = 0 and show a label with the "No results found" message. Ideally i would like something like the ASP .NET datagrid EmptyTemplate solution.

                  干杯

                  推荐答案

                  我已经用这段代码取得了一些成功:

                  I've had some success with this code:

                  <Style TargetType="ListBox" x:Key="ListStyle" BasedOn="{StaticResource {x:Type ListBox}}">
                      <Style.Triggers>
                          <DataTrigger 
                              Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Items.Count}" 
                              Value="0"
                              >
                              <Setter Property="Template">
                                  <Setter.Value>
                                      <ControlTemplate>
                                          <TextBlock>No items to display</TextBlock>
                                      </ControlTemplate>
                                  </Setter.Value>
                              </Setter>
                          </DataTrigger>
                      </Style.Triggers>
                  </Style>
                  

                  这篇关于WPF 列表框空数据模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:ListBox 鼠标悬停在背景颜色上 下一篇:ItemContainerGenerator.ContainerFromItem 如何处理分组列表?

                  相关文章

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

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