c# - 如何在我选择它之前禁用 PivotItem 加载?(UWP C#)
问题描述
我需要使用 Pivot 但不加载所有 PivotItems 中的所有页面。只有当我选择这个特定的 PivotItem 时,才需要加载/重新加载 PivotItem 中的每个页面。
我已经尝试过,再见,Xaml 提供的所有功能,仅在 PivotItem 被按下但未成功时才执行操作。
<Pivot x:Name="XmlConfigPivot">
<PivotItem Header="Layout">
<Frame>
<xml_config:Layout_Tab/>
</Frame>
</PivotItem>
<PivotItem Header="stub_tab">
<Frame>
<xml_config:Stub_Tab/>
</Frame>
</PivotItem>
</Pivot>
仅当我选择它是 PivotItem 时,如何使“xml_config:Layout_Tab”加载?
解决方案
As @Bruno said, you could directly load each page by programming. You just need to register the SelectionChanged event for the Pivot and add some code logic to achieve it.
The following is a simple code sample for your reference:
<Pivot x:Name="XmlConfigPivot" SelectionChanged="XmlConfigPivot_SelectionChanged">
<PivotItem Header="Layout">
<Frame>
</Frame>
</PivotItem>
<PivotItem Header="stub_tab">
<Frame>
</Frame>
</PivotItem>
</Pivot>
private void XmlConfigPivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
PivotItem item = ((sender as Pivot).SelectedItem) as PivotItem;
string header = item.Header.ToString();
Frame frame = item.Content as Frame;
switch (header)
{
case "Layout": frame?.Navigate(typeof(page1)); break;
case "stub_tab": frame?.Navigate(typeof(page2)); break;
}
}
推荐阅读
- python-3.x - 在图像上数鱼
- python-3.x - 找不到 Python2 命令
- reactjs - 无法更改字体大小
- android - 自迁移到 kotlin 以来,getData() 无法正常工作
- elasticsearch - 具有索引名称的 ReactiveCrudRepository 供应
- azure - 如何同意通过 Microsoft Graph Webhook API 订阅?
- reactjs - 如何将`props`传递给TypeScript中的另一个组件
- r - 如何在小标题中的行之间进行操作?
- python - 用户在 Qt 设计器中选择后如何更改行编辑的颜色
- list - 列表中的 SwiftUI 选择不适用于重复使用的单元格