当前位置:网站首页>c#通过frame 和 page 切换页面
c#通过frame 和 page 切换页面
2022-07-07 12:10:00 【孔雀东南飞-深圳】
背景 需要给一个项目添加licence功能 需要做个licence 页 然后mainwindow里面切换主页和登录页 为此 需要将 页面分开来
实现思路 在 mainwindow 中创建一个 frame 然后在对应的 cs 依据 licence 来判断是否加载主页
1 在 mainwindow 中使用 frame
<Grid>
<Frame
Grid.Row="1"
x:Name="frmMain"
Margin="0,0,0,0"
NavigationUIVisibility="Hidden" FontSize="18">
</Frame>
</Grid>
2 创建page 添加现有项 选择page 例如添加了 MainHolePage.xaml
3 在mainwindow 中指定显示的页
frmMain.Source = new Uri("View/MainHoldPage.xaml", UriKind.Relative);
ps:
1 添加到page之后发现keydown事件不能触发 后来解决了:
1 在 page 中写:
Loaded="Page_Loaded"
2 在对应的事件中写:
private void Page_Loaded(object sender, RoutedEventArgs e)
{
var window = Window.GetWindow(this);
window.KeyDown += Page_KeyDown;
}
3 然后page的keydown事件就可以触发了
或者采用广播的形式 但是比较复杂
边栏推荐
- mysql ”Invalid use of null value“ 解决方法
- C语言数组相关问题深度理解
- 数据库系统概论-第一章绪论【概念模型、层次模型和三级模式(外模式、模式、内模式)】
- Navicat run SQL file import data incomplete or import failed
- [untitled]
- XML文件的解析操作
- Seven propagation behaviors of transactions
- Excerpt from "misogyny: female disgust in Japan"
- Clickhouse (03) how to install and deploy Clickhouse
- Redis 核心数据结构 & Redis 6 新特性详
猜你喜欢
供应链供需预估-[时间序列]
Take you to master the three-tier architecture (recommended Collection)
最佳实践 | 用腾讯云AI意愿核身为电话合规保驾护航
2022-7-6 初学redis(一)在 Linux 下下载安装并运行 redis
Did login metamask
"New red flag Cup" desktop application creativity competition 2022
使用day.js让时间 (显示为几分钟前 几小时前 几天前 几个月前 )
Enregistrement de la navigation et de la mise en service du robot ROS intérieur (expérience de sélection du rayon de dilatation)
AI人才培育新思路,这场直播有你关心的
Xshell connection server changes key login to password login
随机推荐
The reason why data truncated for column 'xxx' at row 1 appears in the MySQL import file
2022-7-7 Leetcode 34.在排序数组中查找元素的第一个和最后一个位置
最长上升子序列模型 AcWing 1014. 登山
【面试高频题】难度 2.5/5,简单结合 DFS 的 Trie 模板级运用题
postgresql array类型,每一项拼接
PostgreSQL array type, each splice
Wired network IP address of VMware shared host
接口自动化测试-接口间数据依赖问题解决
Solve the cache breakdown problem
请问,PTS对数据库压测有好方案么?
566. 重塑矩阵
Vmware 与主机之间传输文件
《厌女:日本的女性嫌恶》摘录
【堡垒机】云堡垒机和普通堡垒机的区别是什么?
内存溢出和内存泄漏的区别
The meaning of variables starting with underscores in PHP
Xshell connection server changes key login to password login
Realization of search box effect [daily question]
The delivery efficiency is increased by 52 times, and the operation efficiency is increased by 10 times. See the compilation of practical cases of financial cloud native technology (with download)
AI talent cultivation new ideas, this live broadcast has what you care about