The problem of region clipping occurs when VisualBrush and Rotatetransform are used together
See original GitHub issue- .NET Core Version:.NET 6
- Windows version: Windows 11
- Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes
Problem description: I want to implement a tiled and rotated watermark effect in wpf But when I use VisualBrush and RotateTransform, the excess area is clipped
Actual behavior: 【VisualBrush without RotateTransform】
【VisualBrush with RotateTransform】
Expected behavior: I found a html demo like this:
or this:
Minimal repro: xaml code
<Grid ClipToBounds="False">
<Grid.Background>
<VisualBrush
Stretch="None"
TileMode="Tile"
Viewport="0,0,100,50"
ViewportUnits="Absolute">
<VisualBrush.Visual>
<TextBox
Width="100"
Height="50"
HorizontalAlignment="Center"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
Background="Blue"
Foreground="White"
Text="Hello .NET 6">
<TextBox.RenderTransform>
<RotateTransform Angle="45" CenterX="50" CenterY="25" />
</TextBox.RenderTransform>
</TextBox>
</VisualBrush.Visual>
</VisualBrush>
</Grid.Background>
</Grid>
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
WPF clip rectangle with path not getting desired output
I want to clip water rectangle in a way such that it only displayed in container. I have tried clipping using path geometry...
Read more >Mitigating Airspace Issues In WPF Applications
Painting operations are clipped to the visible regions of ancestors. This means that child windows cannot paint outside of their parent windows.
Read more >WPF Interview Questions And Answers
This article lists the most asked WPF Interview questions and answers. What is WPF? How to learn WPF? WPF tutorials.
Read more >How to: Use Clipping with a Region - Windows Forms .NET ...
The region is passed to the SetClip method of a Graphics object, and then two strings are drawn. The following illustration shows the...
Read more >WPF and Silverlight Super-Productivity: ListBoxes
The clipping region is a simple rectangle with a width based on that rating. That particular clipping rectangle is created by a binding...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for your reply.
I found that your code can only work properly under specific circumstances, but if The Grid’s width and height isn‘t auto,or TextBox’s angle is bigger than 15 will not take effect~ like this:
actually, in my actual development process, the angle, the Width and Height of the Grid, and the content of the TextBox can change dynamically
Sorry, this may be a complicated requirement, and I hope it can be solved
(by the way 林德熙大佬, I often see your articles, ha ha😁)
Two problem:
The fixed code:
The demo code: https://github.com/lindexi/lindexi_gd/tree/fa7dfe687c00baaf083c875afa36d0b223a972b8/DakajoheachuNercairrihijal