確實很痛苦:您需要一個可導航到頁面的導航窗口。由於這是從Window繼承的,因此您可以在此容器上設置Height和Width。
- 打開一個新的WPF應用程序
- 刪除您獲得的標準窗口1。因此
<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:
更改的App.xaml這樣(刪除的StartupUri屬性)
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>
祝你好運!
謝謝,那正是我需要的!這樣也可以設置其他的東西像ReSizeMode等 – 2009-10-26 20:19:30