Closed spiovesan closed 11 years ago
good to hear it's working as intended :) http://blogs.msdn.com/b/dwayneneed/archive/2013/02/26/mitigating-airspace-issues-in-wpf-applications.aspx see: https://github.com/MahApps/MahApps.Metro/issues/488
the idea is try find another solution and no use the other DLL ...
Well after peeking through the code I think I found the culprit.
This should fix it for .NET 4.5 without referencing additional dll. MA.M for .NET 4 client profile can use the source code from here http://archive.msdn.microsoft.com/WPFShell/Release/ProjectReleases.aspx?ReleaseId=4332, or ILMerge the Microsoft.Windows.Shell.dll
Hi, thank you for your help! I was able to make the HwndHost working using DwayneNeed and 4.0 with the AirspaceDecorator. I am not able to make the HwndHost working with latest Mahapps and 4.5 without additional dlls. I have some random errors with the VS2010 designer using DwayneNeed and now I am looking how to make the HwndHost working with Microsoft.Windows.Shell. May I have some quick suggestion how to use it?
Have you tried your project with MA.M make-windowchrome-not-suck branch?
Also, a fix for AirspaceDecorator borking the XAML designer issue: Set AirspaceDecorator.AirspaceMode to "None" in XAML, and change it to "Clip" or "Redirect" in runtime.
Thanks for the suggestions. I tried the make-windowchrome-not-suck, but unfortunately the WindowsFormsHost does not work with a derived HwndHost element. Probably I should encapsulate my dialog in a WindowsForms Control to make it working. I have a question about the solution I should go: my real application is a vision system application, showing images in real time display too (the MFC part is a third part library with an CWnd ‘console’, where you can show images and graphics; this component is using DirectDraw). I have some concern using the AirspaceDecorator, that would decrease the performances requiring additional CPU work. Instead hosting the CWnd console in a WindowsForms Control should not require any additional CPU work. What do you think?
@spiovesan: It is because BorderlessWindowBehavior
sets Window.AllowsTransparency = true
This is how your "hwndinwpf" demo works without AllowsTransparency
Here again.. I used the AirspaceDecorator on my desktop PC (a HP 8100 i5) with no problems. Then I installed the same application on a production PC (Windows7 embedded with a i7) and the application started sucking (idle) 50% of the CPU and memory (up to 1 GB). The issue is the AirspaceDecorator, but I have no idea why... Then I am trying another way, embedding my MFC classes in a WindowsFormsControl. As before, this works with a plain wpf but the control is invisible with the Metro style (even without AllowsTransparency). The sample application is here https://github.com/spiovesan/GithubSamples/tree/master/MyWindowsFormControlProj. Thank you for any help!
@spiovesan lets see: You downloaded MA.M code. removed AllowTransparency assignment statement from BorderlessWindowBehavior (what I said in my previous post), recompiled, and didn't see this:
(https://github.com/MahApps/MahApps.Metro/pull/503#issuecomment-19036221)
Sorry my fault… When removing the AirspaceDecorator I forgot to add the behaviours:BorderlessWindowBehavior/ section. Now it works with both the solutions (HwndHost and WidowsFormControl) and with no CPU load. Thank you for yor help.
We would like to update the MahApps.Metro-make-windowchrome-not-suck we are using but the branch is disappeared and the latest MahApps 0.99 does not work. Is this branch still maintained, in a new branch or merged?
@spiovesan have you tried the latest alpha?
I tried this one @ https://github.com/MahApps/MahApps.Metro/archive/master.zip downloaded yesterday. Is this correct?
@spiovesan Yes. That's more or less the same code the alpha uses.
The sample @ https://github.com/spiovesan/GithubSamples/tree/master/MyWindowsFormControlProj. is working with the branch. Referencing the latest MahApps.Metro build, I got 'System.Windows.Interactivity.BehaviorCollection' error when loading the xaml page. The application starts removing the EnableDWMDropShadow="True" attribute but the MFC is not shown anymore
Any idea how to align the current release with the MahApps.Metro-make-windowchrome-not-suck branch? Thanks.
If I remember correctly, that branch was merged into the main code months ago.
EDIT: If you /need/ that specific branch /that/ badly, I can bring the branch back but it won't be updated should you find a bug in it since it's been merged. If we were to fix a bug, we would create a new branch.
I posted here a sample @ https://github.com/spiovesan/GithubSamples/tree/master/MyWindowsFormControlProj. that was working with that branch. Just referencing the latest MahApps.Metro build the sample does not work anymore. I get 'System.Windows.Interactivity.BehaviorCollection' error when loading the xaml page. I would like to use latest mahapps. It is not possible making the branch behavior working within the main code?
@spiovesan That issue is because of:
<behaviours:BorderlessWindowBehavior ResizeWithGrip="True" EnableDWMDropShadow="True" />
In order for DropShadow to be enabled, AllowsTransparency must be False.
<behaviours:BorderlessWindowBehavior ResizeWithGrip="True" EnableDWMDropShadow="True" AllowsTransparency="False" />
EDIT: Also, recent changes have renamed "Colours.xaml" to "Colors.xaml".
EDIT2: Setting AllowsTransparency to false allows your control to render. This is maybe related to the airspace issue: #488
Great! Thank you for your help.
I have a MFC dialog showed in a WPF application using a HwndHost class. The basic code is quite simple
This works is a standard WPF application. If the WPF window becomes a MetroWindow class, the dialog area (where MFC buttons where displayed) is completely white. I noticed that commenting the
<Behaviours:BorderlessWindowBehavior/>
in the<Style TargetType="{x:Type Controls:MetroWindow}">
inMetroWindow.xaml
make it working (but with an extra old style title bar).A sample is here https://github.com/spiovesan/hwndwpfmetro (change StartupUri="WindowMetro.xaml" too see metro style) Please help! Ciao, Stefano