Winforms Marquis stops working in WPF

Richard Jian 41 Reputation points
2021-11-08T03:10:10.247+00:00

Hi Guys,
Winforms Marquis stops working in WPF environment.
Here is the source code.
s!Ag7LlPZhmWxciyRICdiZlB1UVxxQ

XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
768 questions
0 comments No comments
{count} votes

Accepted answer
  1. Hui Liu-MSFT 40,786 Reputation points Microsoft Vendor
    2021-11-08T08:21:15.23+00:00

    If you want to open the winform window in wpf and display the progress bar normally at runtime, you could add the following code to your project.

               System.Windows.Forms.Application.EnableVisualStyles();  
               System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);  
      
    

    The content comes from the document Application.SetCompatibleTextRenderingDefault(Boolean) Method

    You can only call this method before the first window is created by your Windows Forms application.

    I added the above code in the MainWindow method instead of Form1.Designer.cs and it works normally

      public partial class MainWindow : Window  
            {  
                public MainWindow()  
                {  
                    InitializeComponent();  
                    System.Windows.Forms.Application.EnableVisualStyles();  
                    System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);  
                }  
          }  
    

    The picture of result:

    147311-3.gif


    If the answer is the right solution, please click Accept Answer and kindly upvote it. If you have extra questions about this answer, please click Comment.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful