繁体   English   中英

有没有办法从导航页面更改主机窗口的大小和样式? (WPF)

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

我有一个主机窗口,其页面如下:

 <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>

然后在 C# 的代码中,我调用另一个页面,如下所示:

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

此时我想更改宿主窗口的大小和样式。

有没有办法做到这一点?

欢迎任何建议或意见。

可以使用以下代码改变Page中MainWindow的大小

  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;


        }
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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