c# - 操作子框架内的控件的最佳方法是什么?(UWP)
问题描述
我不确定在页面的子框架内操作控件的最佳方法是什么。看:
<Page x:Name="ParentPage">
<!-- ParentPage contains a button. When the button is clicked I would like to select all the items in a ListView that is in the InnerPage Page. -->
<Frame x:Name="SubFrame">
<Page x:Name="InnerPage" />
</Frame>
</Page>
现在 InnerPage 实际上是通过 C# 代码加载的,因为实际上有几个不同的 Pages 被加载到 SubFrame 框架中,因此很难像下面的示例那样做一些事情。但是,加载到子帧框架中的所有页面都包含完全相同的 ListView。
public sealed partial class ParentPage : Page
{
public ParentPage()
{
InnerPage _InnerPage = SubFrame.Content as InnerPage;
_InnerPage.SelectAllListViewItems();
}
}
解决方案
不太清楚为什么在 SubFrame 中使用具有相同 ListView 的不同内页以及要实现的实际效果。但是你可以尝试在你的项目中添加一些不同的页面,然后在页面的代码后面对页面进行操作,这样管理页面会更容易。
在父页面中,您可以使用Frame.Navigate 方法来加载您的子页面。
SubFrame.Navigate(typeof(ChildPage));
推荐阅读
- c# - 使用条件 json.net 反序列化对象
- java - AbstractCreatorProcessor 类未找到错误
- c - 如何在恒定时间内检查一组非重叠范围内的范围
- c++ - 当我将值放入数组时,变量被覆盖
- javascript - 无法在 html 表的下拉列表中显示 JSON 数据
- java - 如何区分未注册用户和注册用户的内容
- android - 删除+替换片段后不调用 onOptionsItemSelected
- javascript - 如何从 .env 文件 GatsbyJS、React 中读取变量?
- r - Qwraps2- 行组标签未显示在汇总表中
- python-2.7 - 由于 EnvironmentError 无法安装软件包:当我安装 AWS CLI 时