mfc mixing wpf and winforms

mfc mixing wpf and winforms

Old forum URL: forums.lhotka.net/forums/t/6096.aspx


PederSvaleng posted on Wednesday, January 07, 2009

We are hosting both winforms and wpf user controls in our MFC application. Will there be any issues around the CslaPropertyChangedMode in the app.config?

<add key="CslaPropertyChangedMode" value="Xaml" />

Will I encounter any problems mixing winforms and wpf?

ajj3085 replied on Wednesday, January 07, 2009

Hmm... good question.  I have some very limited mixing.. I created a simple Xaml UserControl inside my Winforms application.  Everything seems to work fine for that... but the control is very simple.

I'm going to be doing more integration later (pulling more complicated Xaml UserControls into Wpf), so this is something I may have to watch.  Unfortunately I don't have an answer myself...

RockfordLhotka replied on Wednesday, January 07, 2009

Hmm, you might.

The thing to understand is that Windows Forms does a full refresh of bound controls on every PropertyChanged event. XAML does a refresh of only the specific property that has changed.

So in Windows Forms, as a general rule, the goal is to raise as few PropertyChanged events as possible.

And in WPF, as a general rule, you want to raise a PropertyChanged event for any changed property (or property with a changed validation rule state).

What this means is that the "Xaml" mode will work for WinForms mode, but the WinForms mode won't work for WPF. It also means that the "Xaml" mode will be slightly less efficient in WinForms, because it will trigger more UI refreshes - but that really might not be a big deal unless you have many dozens of bound controls to a single object instance (like an object with 100 properties could maybe be a problem).

PederSvaleng replied on Thursday, January 08, 2009

Thanks to both of you!! That was very clarifying!

Copyright (c) Marimer LLC