MahApps / MahApps.Metro

A framework that allows developers to cobble together a better UI for their own WPF applications with minimal effort.
https://mahapps.com
MIT License
9.29k stars 2.45k forks source link

MahApps.MetroWindow is invisible in ScreenCap programs #628

Closed CBenni closed 11 years ago

CBenni commented 11 years ago

I faced this issue when trying to write a program that is needed to work on livestreams: I create a default MetroWindow and it (including controls on the Window) is just 100% transparent!

I created a MWE: mahappsbug1 This picture was taken with the default "print screen" feature of Windows.

On the other side, the same situation in Open Broadcaster Software: mahappsbug2

The window is completely transparent! Adding the resources to the code didnt change anything about the visibility. I tested around with window capture, my screencap programs (I tested with XSplit, OBS and VHScrCap) find the window but show it as completely transparent.

Is there a quick fix to this? On the long run, this might be an issue that has to be fixed permanently.

The code I was using for this MWE is just

<Controls:MetroWindow x:Class="MahAppsMetroMWE.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
        Title="MainWindow" Height="350" Width="525" Background="#FF343434">
    <Grid>

    </Grid>
</Controls:MetroWindow>

Adding controls or the MahApps resources (as seen in the documentation getting started section) does not resolve any of this.

AzureKitsune commented 11 years ago

Interesting. Oh, and your Opacity should equal "1.0", not "100". In WPF, Opacity is a float/double instead of an integer.

As far as the invisibility goes, I'll take a look in the code for any possible reasons later today.

CBenni commented 11 years ago

Thanks about that Opacity thing, I didnt know that - doesnt make a difference tho.

AzureKitsune commented 11 years ago

@CBenni Off the top of my head, could you try adding AllowsTransparency="False" to your window?

CBenni commented 11 years ago

@Amrykid No it does not - I have gone through most of the direct members of Window/MetroWindow and tried them out. Only thing that fixed the issue was changing MetroWindow to Window...

AzureKitsune commented 11 years ago

OK, @CBenni I can take a look in the code now. I'll report back with my findings.

EDIT: Ah ha. Figured it out. It is related to AllowsTransparency.

I figured something was off when my metro app shows up in OBS. b1

The issue is related to the implicit BorderlessWindowBehavior (which has AllowsTransparency set to true by default). Simply add this to your window:

    <i:Interaction.Behaviors>
        <Behaviors:BorderlessWindowBehavior AllowsTransparency="False"/>
    </i:Interaction.Behaviors>

After that, it should work fine. Like so: b2

CBenni commented 11 years ago

Awesome! Thank you. Is this still considered a bug? Could this be patched in general or does it hide wanted behaviour? It works fine now however.

AzureKitsune commented 11 years ago

It's not a bug. It is off by default in order to have a 'glow' around MetroWindows instead of the Drop Shadow provided by Windows Aero (in Vista, 7 and 8).

Konrud commented 10 years ago

I have the same issue, i tried to add

image

but it still shows black screen behind .

image