简体   繁体   中英

Is there a way to change the size and style of a host window from a navigationpage? (WPF)

I have a host window that has a page as follows:

 <Window x:Class="myAPP.filesXAML.WinModel" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:myApp.filesXAML" mc:Ignorable="d" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None" Title="myAPP" Height="562" Width="1000"> <Grid> <Frame NavigationUIVisibility="Hidden" Source="/filesXAML/Login.xaml" Background ="White"/> </Grid> </Window>

Then in the code in C# I call another page as follows:

 NavigationService.Navigate(new Uri("filesXAML/UserPage.xaml", UriKind.Relative));

At this point I want to change the size and style of the host window.

Is there a way to do it?

Any suggestions or comments are welcome.

You can use the following code to change the size of MainWindow in Page

  public partial class Page1 : Page
    {
        public Page1()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {

            Application.Current.Windows[0].Width = 100;
            Application.Current.Windows[0].Height = 100;


        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM