Skip to content

Migrating an UWP app based on MVVM to WinUI in Desktop #1678

Answered by VigneshVoid
VigneshVoid asked this question in Q&A
Discussion options

You must be logged in to vote

We resolved by both the issue by getting windowhandle. We have created a simple WindowHelper to address in every stage of View and ViewModel.

public class WindowHelper
    {
        public static Window CurrentWindow { get; set; }

        public static int CurrentWindowId { get; set; }

        public static AppWindowTitleBar TitleBar { get; set; }

        public static void LoadWindow(Window window)
        {
            CurrentWindow = window;
            IntPtr windowHandle = WinRT.Interop.WindowNative.GetWindowHandle(CurrentWindow);
            WindowId id = Win32Interop.GetWindowIdFromWindow(windowHandle);
            CurrentWindowId = (int)id.Value;
            TitleBar = AppWindo…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by VigneshVoid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant