Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我希望使用 XAML 创建一个类似界面的计算器。它应该包含最多 1000 个按钮。我已经阅读了有关虚拟化堆栈面板的信息,但我不确定如何将它与列表框一起使用并与该列表进行数据绑定以获取内容. 你能帮我虚拟化堆栈面板的概念吗
ListBox默认情况下包含一个虚拟化StackPanel,所以你不需要担心它,或者如何实现它。StackPanel仅供参考,当它们进入视图时,虚拟化仅创建 UI 元素(在您的情况下为按钮)。另一个改进是打开容器回收:
ListBox
StackPanel
<ListBox VirtualizingStackPanel.IsVirtualizing="true" VirtualizingStackPanel.VirtualizationMode="Recycling" />