当前位置:网站首页>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" solution
- toRaw和markRaw
- What are the principles for distinguishing the security objectives and implementation methods that cloud computing security expansion requires to focus on?
- SSRF漏洞file伪协议之[网鼎杯 2018]Fakebook1
- The meaning of variables starting with underscores in PHP
- Laravel form builder uses
- docker部署oracle
- . Net core about redis pipeline and transactions
- Battle Atlas: 12 scenarios detailing the requirements for container safety construction
- 2022-7-6 sigurg is used to receive external data. I don't know why it can't be printed out
猜你喜欢

MySQL error 28 and solution

Redis只能做缓存?太out了!

Sliding rail stepping motor commissioning (national ocean vehicle competition) (STM32 master control)
![[fortress machine] what is the difference between cloud fortress machine and ordinary fortress machine?](/img/fb/17e029b1d955965d7e2e0f58701d91.png)
[fortress machine] what is the difference between cloud fortress machine and ordinary fortress machine?

LeetCode简单题分享(20)

Navicat run SQL file import data incomplete or import failed

带你掌握三层架构(建议收藏)

. Net core about redis pipeline and transactions

室内ROS机器人导航调试记录(膨胀半径的选取经验)

docker部署oracle
随机推荐
Custom thread pool rejection policy
Flask session forged hctf admin
C语言数组相关问题深度理解
[untitled]
【网络安全】sql注入语法汇总
最佳实践 | 用腾讯云AI意愿核身为电话合规保驾护航
Is the compass stock software reliable? Is it safe to trade stocks?
Attribute keywords aliases, calculated, cardinality, ClientName
How can the PC page call QQ for online chat?
Details of redis core data structure & new features of redis 6
Excuse me, why is it that there are no consumption messages in redis and they are all piled up in redis? Cerely is used.
【日常训练--腾讯精选50】231. 2 的幂
《厌女:日本的女性嫌恶》摘录
请问,redis没有消费消息,都在redis里堆着是怎么回事?用的是cerely 。
The difference between memory overflow and memory leak
MySQL "invalid use of null value" solution
【AI实战】应用xgboost.XGBRegressor搭建空气质量预测模型(二)
Indoor ROS robot navigation commissioning record (experience in selecting expansion radius)
Redis只能做缓存?太out了!
Redis can only cache? Too out!