J'écris un pinceau en XAML que je peux utiliser pour peindre l'arrière-plan d'un Grid
pour créer une bannière. Il ressemble à ceci:Prévention de la déformation dans l'arrière-plan de XAML Grid lors du redimensionnement
An example of the brush applied to the background of a Grid http://i40.tinypic.com/8wl012.png
Je veux la brosse à « étirer » avec le Grid
lorsque le Window
redimensionne, mais je ne veux pas le centre des angles à se déformer.
The deformed background brush http://i39.tinypic.com/2nly98p.png
Je ne doivent être en mesure de dessiner les formes en arrière-plan d'un Grid
. Comment puis-je éviter la déformation?
Le code que j'ai écrit ressemble à ceci:
<Window x:Class="WpfApplication.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="60" Width="300">
<Window.Resources>
<DrawingBrush x:Key="GridBackground">
<DrawingBrush.Drawing>
<DrawingGroup>
<DrawingGroup.Children>
<GeometryDrawing Geometry="M0,1 0,0 0.4,0 0.45,0.5 0.4,1Z" Brush="#FF6A00" />
<GeometryDrawing Geometry="M0.6,1 0.55,0.5 0.6,0 1,0 1,1Z" Brush="#FF0000" />
</DrawingGroup.Children>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</Window.Resources>
<Grid Background="{StaticResource GridBackground}">
<TextBlock Foreground="White" VerticalAlignment="Center">Some text</TextBlock>
</Grid>
</Window>
Il est important que les formes soient en arrière-plan de la grille. Le seul changement que je souhaite apporter à la grille elle-même consiste à ajouter l'attribut Background. –