当前位置:网站首页>C # switch pages through frame and page

C # switch pages through frame and page

2022-07-07 14:12:00 Peacock Flying Southeast - Shenzhen

background You need to add licence function We need to make a decision licence page then mainwindow Switch between home page and login page So Need to put Separate pages

Realize the idea stay mainwindow Create a frame And then in the corresponding cs basis licence To determine whether to load the home page

1 stay mainwindow Use in frame

<Grid>
    <Frame
        Grid.Row="1"
        x:Name="frmMain"
        Margin="0,0,0,0"
        NavigationUIVisibility="Hidden" FontSize="18">
    </Frame>
</Grid>

2 establish page Add an existing item choice page For example, added MainHolePage.xaml

3 stay mainwindow Specify the page to display

frmMain.Source = new Uri("View/MainHoldPage.xaml", UriKind.Relative);

ps:

1 Add to page And then I found out keydown Event cannot be triggered It was solved later :

1  stay  page  Write in :

Loaded="Page_Loaded"

2  Write in the corresponding event :

private void Page_Loaded(object sender, RoutedEventArgs e)
{
     var window = Window.GetWindow(this);
     window.KeyDown += Page_KeyDown;
}

3  then page Of keydown The event can be triggered 

 Or in the form of broadcasting   But it's more complicated 

原网站

版权声明
本文为[Peacock Flying Southeast - Shenzhen]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071209532858.html