question

RichardJian-0723 avatar image
0 Votes"
RichardJian-0723 asked RichardJian-0723 commented

Winforms Marquis stops working in WPF

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


dotnet-wpf-xaml
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

HuiLiu-MSFT avatar image
1 Vote"
HuiLiu-MSFT answered RichardJian-0723 commented

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.


3.gif (82.3 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks a lot, HuiLiu.

I do get the result as shown in your answer.
However, when I close Form1 and re-click the button on the MainWindow. The MainWindow will collapse a few seconds later.
Thanks again.

0 Votes 0 ·

Hi,@RichardJian-0723 . I updated my answer, you could check it out.

0 Votes 0 ·

Yes! It works perfectly!
Thank you very much! HuiLiu

0 Votes 0 ·