当前位置:网站首页>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事件就可以触发了
或者采用广播的形式 但是比较复杂边栏推荐
猜你喜欢
随机推荐
Social responsibility · value co creation, Zhongguancun network security and Information Industry Alliance dialogue, wechat entrepreneur Haitai Fangyuan, chairman Mr. Jiang Haizhou
Excellent open source system recommendation of ThinkPHP framework
MySQL "invalid use of null value" solution
2022-7-7 Leetcode 34.在排序数组中查找元素的第一个和最后一个位置
Learning breakout 2 - about effective learning methods
Supply chain supply and demand estimation - [time series]
[untitled]
Realization of search box effect [daily question]
Flask session forged hctf admin
MySQL error 28 and solution
Clickhouse (03) how to install and deploy Clickhouse
AutoCAD - how to input angle dimensions and CAD diameter symbols greater than 180 degrees?
请问指南针股票软件可靠吗?交易股票安全吗?
2022-7-6 初学redis(一)在 Linux 下下载安装并运行 redis
Common response status codes
. Net core about redis pipeline and transactions
Best practice | using Tencent cloud AI willingness to audit as the escort of telephone compliance
Oracle advanced (V) schema solution
室内ROS机器人导航调试记录(膨胀半径的选取经验)
118. Yanghui triangle









