dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.08k stars 1.17k forks source link

Popup inherits transformation depending on AllowsTransparency #5530

Open topsterde opened 3 years ago

topsterde commented 3 years ago
huiliu-code commented 3 years ago

The reason why RotateTransform is not applied is because AllowsTransparency is false. Without this, the Popup has to stay rectangular. If you set it to true the rotation will also be applied. You could use the following method or refer to the method here.

<Grid Margin="50" Width="100" Height="100" HorizontalAlignment="Center" VerticalAlignment="Center" Background="LightGray">
        <Grid.LayoutTransform>
            <RotateTransform Angle="45" />
        </Grid.LayoutTransform>
         <Popup IsOpen="True" Placement="Center" AllowsTransparency="False">
            <Border Background="Green">
                <TextBlock Text="Popup without AllowsTransparency"/>
            </Border>
        </Popup>
        <Popup IsOpen="True" Placement="Center" AllowsTransparency="True" >
            <Popup.LayoutTransform>
                 <RotateTransform Angle="-45" />
            </Popup.LayoutTransform>
            <Border Background="Yellow">
                <TextBlock Text="Popup with AllowsTransparency"/>
            </Border>
        </Popup>
      </Grid>