• 1000 * Я не могу заставить окно помощника быть маленьким. «Всегда сверху» в этом окне работает нормально.
Я слежу за примерами UWP:
- режим всегда сверху работает с: uwp samples / app window / overlay
- делает окно маленьким (не работает) из: uwp samples / app window / size
Мой текущий код такой, как показано ниже.
Есть идеи, как сделать окно «помощника» маленьким?
public sealed partial class MainPage : Page
{
private AppWindow appWindow;
private Frame appWindowFrame = new Frame();
async void ShowHelperWindow()
{
// Is CompactOverlay supported for our main window?
// If so, it will be supported for a new window as well.
// If it isn't, it will not be supported for new windows either so we cannot proceed.
if (!ApplicationView.GetForCurrentView().IsViewModeSupported(ApplicationViewMode.CompactOverlay))
{
return;
}
if (appWindow == null)
{
// Create a new AppWindow
appWindow = await AppWindow.TryCreateAsync();
// Make sure we release the reference to this window, and release XAML resources, when it's closed
appWindow.Closed += delegate { appWindow = null; appWindowFrame.Content = null; };
// Is CompactOverlay supported for this AppWindow? If not, then stop.
if (appWindow.Presenter.IsPresentationSupported(AppWindowPresentationKind.CompactOverlay))
{
// Create a new frame for the window
// Navigate the frame to the CompactOverlay page inside it.
appWindowFrame.Navigate(typeof(TimerStatusPage));
var size = new Size(192, 48);
WindowManagementPreview.SetPreferredMinSize(appWindow, new Size(192, 48));
// Request the size of our window
appWindow.RequestSize(size);
// Attach the frame to the window
ElementCompositionPreview.SetAppWindowContent(appWindow, appWindowFrame);
// Let's set the title so that we can tell the windows apart
appWindow.Title = "size:" + size;
// Request the Presentation of the window to CompactOverlay
bool switched = appWindow.Presenter.RequestPresentation(AppWindowPresentationKind.CompactOverlay);
if (switched)
{
// If the request was satisfied, show the window
await appWindow.TryShowAsync();
}
}
}
else
{
await appWindow.TryShowAsync();
}
}
... rest of class