The content of a ListView with ItemsPanel modified is not shown in designer (VS and Blend)

帅比萌擦擦* 提交于 2019-12-23 04:50:49

问题


I have this code:

          <ListView Margin="0,10,0,0">
                <!--Orientation="Horizontal"-->
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapGrid Orientation="Horizontal" />
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>

                <ListView.Items>
                    <AppBarButton Icon="Download"
                                  IsCompact="False"
                                  Label="Stáhnout test"
                                  HorizontalAlignment="Center"></AppBarButton>
                    <AppBarButton Icon="Play"
                                  IsCompact="False"
                                  Label="Spustit test"
                                  HorizontalAlignment="Center"></AppBarButton>
                    <AppBarButton Icon="Attach"
                                  Grid.Column="4"
                                  IsCompact="False"
                                  Label="Otevřít přílohu testu"
                                  HorizontalAlignment="Center"></AppBarButton>
                    <AppBarButton Icon="ShowResults"
                                  IsCompact="False"
                                  Label="Výsledky"
                                  HorizontalAlignment="Center"></AppBarButton>
                    <AppBarButton Icon="Delete"
                                  IsCompact="False"
                                  Label="Smazat cache"
                                  HorizontalAlignment="Center"></AppBarButton>
                </ListView.Items>
        </ListView>

... and it works fine during runtime. When there is not enough horizontal space, some app bar buttons are rendered on the next line (the content of listview is wrapped), which is what I want. I found this solution here: Windows 8 WrapPanel .

The problem is that the designer (VS and also Blend) do not show the content of the lsitview at all. If I comment out the ListView.ItemsPanel section, the designer is back in the game.

Is there a way how to overcome this issue?


回答1:


This is a known problem with the designer and is being investigated for a fix in future versions.

If you are targeting Windows 8.1 then using an ItemsWrapGrid instead of a WrapGrid is recommended. The ItemsWrapGrid will show up correctly both in the designer and at runtime.

--Rob



来源:https://stackoverflow.com/questions/25993352/the-content-of-a-listview-with-itemspanel-modified-is-not-shown-in-designer-vs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!