それは確かに面倒です: ページにナビゲートできる NavigationWindow が必要です。これは Window から継承されるため、このコンテナーの高さと幅を設定できます。
-新しい wpf アプリケーションを開きます -取得した標準 window1 を削除します
。
App.xaml を次のように変更します (StartupUri 属性を削除します)。
<Application x:Class="WpfApplication1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Startup="Application_Startup">
<Application.Resources>
</Application.Resources>
</Application>
App.xaml.cs を次のように記述します。
public partial class App : Application
{
private NavigationWindow navigationWindow;
private void Application_Startup(object sender, StartupEventArgs e)
{
navigationWindow = new NavigationWindow();
navigationWindow.Height = 200;
navigationWindow.Width = 100;
var page = new Page1();
navigationWindow.Navigate(page);
navigationWindow.Show();
}
プロジェクトメニューからページを追加できます。これにより、次のような結果が得られます。
<Page x:Class="WpfApplication1.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Page1">
<Grid>
<TextBlock>test</TextBlock>
</Grid>
</Page>
幸運を!