2
我試圖在Windows 10應用程序中創建一個新窗口,但我希望能夠爲創建的窗口指定初始大小。Windows 10創建初始大小的新窗口
到目前爲止,我想作爲這樣,沒有運氣 -
var currentAppView = ApplicationView.GetForCurrentView();
var newCoreAppView = CoreApplication.CreateNewView();
await newCoreAppView.Dispatcher.RunAsync(
CoreDispatcherPriority.Normal,
async() =>
{
var newWindow = Window.Current;
var newAppView = ApplicationView.GetForCurrentView();
newAppView.SetPreferredMinSize(new Size(1, 1));
newAppView.TryResizeView(new Size(300, 300));
newAppView.Title = "New small window";
var frame = new Frame();
frame.Navigate(typeof(NewPage), null);
newWindow.Content = frame;
newWindow.Activate();
await ApplicationViewSwitcher.TryShowAsStandaloneAsync(
newAppView.Id,
ViewSizePreference.UseMinimum,
currentAppView.Id,
ViewSizePreference.UseMinimum);
});
結果是什麼? – SimpleVar
這當前會創建一個與原始大小相同的窗口。這裏的目標是創建尺寸爲300x300的窗口。 – BradStevenson
看看[這個](http://stackoverflow.com/questions/31885979/windows-10-uwp-app-setting-window-size-on-desktop#31888254)回答你的問題。 – user1325543