当前位置:网站首页>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事件就可以触发了
或者采用广播的形式 但是比较复杂
边栏推荐
- 室内ROS机器人导航调试记录(膨胀半径的选取经验)
- Attribute keywords aliases, calculated, cardinality, ClientName
- Vmware共享主机的有线网络IP地址
- 接口自动化测试-接口间数据依赖问题解决
- call undefined function openssl_ cipher_ iv_ length
- mysql ”Invalid use of null value“ 解决方法
- Common response status codes
- How to check the ram and ROM usage of MCU through Keil
- [fortress machine] what is the difference between cloud fortress machine and ordinary fortress machine?
- Laravel form builder uses
猜你喜欢
最长上升子序列模型 AcWing 1014. 登山
Take you to master the three-tier architecture (recommended Collection)
高等数学---第八章多元函数微分学1
Help tenants
118. Yanghui triangle
MySQL error 28 and solution
社会责任·价值共创,中关村网络安全与信息化产业联盟对话网信企业家海泰方圆董事长姜海舟先生
566. 重塑矩阵
MySQL error 28 and solution
"New red flag Cup" desktop application creativity competition 2022
随机推荐
Excellent open source system recommendation of ThinkPHP framework
Environment configuration
Laravel5 call to undefined function OpenSSL cipher IV length() error php7 failed to open OpenSSL extension
請問,在使用flink sql sink數據到kafka的時候出現執行成功,但是kafka裏面沒有數
Take you to master the three-tier architecture (recommended Collection)
Parameter keywords final, flags, internal, mapping keywords internal
Oracle advanced (V) schema solution
The meaning of variables starting with underscores in PHP
Deep understanding of array related problems in C language
Common response status codes
How can the PC page call QQ for online chat?
C语言数组相关问题深度理解
PC端页面如何调用QQ进行在线聊天?
SSRF vulnerability file pseudo protocol [netding Cup 2018] fakebook1
搜索框效果的实现【每日一题】
[daily training -- Tencent select 50] 231 Power of 2
Learning breakout 2 - about effective learning methods
Wired network IP address of VMware shared host
Mathématiques avancées - - chapitre 8 différenciation des fonctions multivariables 1
带你掌握三层架构(建议收藏)