WPF Window with transparent background containing opaque controls

<>

This question already has an answer here:

Answers


Instead of setting the opacity of the window, set its background's opacity:

<Window x:Class="WpfApplication3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"
        AllowsTransparency="True" WindowStyle="None">
    <Window.Background>
        <SolidColorBrush Opacity="0.5" Color="White"/>
    </Window.Background>
    <Grid>
        <Button Width="200" Height="50">button</Button>
    </Grid>
</Window>

If you create a style like this:

<Window.Resources>
    <Style TargetType="Button" x:Key="WindowButtons">
        <Setter Property="Opacity" Value="1"/>           
    </Style>
</Window.Resources>

Then you can reference those in the XAML for your button like this:

<Button Style="{StaticResource WindowButtons}">Tony</Button>

And it should no longer inherit it's opacity from its parent.


Above effect can also be achieved by setting Opacity from designer from 100% to 60%(as required).


Need Your Help

Maven create jar file with both .class and .java files

java maven gwt

I'm looking for a way to create jar files containing both .class and .java files for GWT modules. Anyone knows how that could be achieved?