[英]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.