Given this XAML:
<Style TargetType="PasswordBox">
<Setter Property="Background">
<Setter.Value>
<VisualBrush TileMode="Tile"
Viewport="0,0,10,10" ViewportUnits="Absolute">
<VisualBrush.Visual>
<Canvas Background="{x:Static SystemColors.WindowBrush}">
<Path Data="M0,0 L10,10 M0,10 L10,0">
<Path.Stroke>
<SolidColorBrush Color="{x:Static SystemColors.HighlightColor}"/>
</Path.Stroke>
</Path>
</Canvas>
</VisualBrush.Visual>
</VisualBrush>
</Setter.Value>
</Setter>
...
The canvas background is being ignored, and instead the path is visible over a background that’s transparent to the form behind the PasswordBox. So where should I be setting the “background for the background”?
The problem is that the
Canvashas no size.Change it to this and you should see it:
To reduce the number of references to those dimensions, you can declare them as resources.
Since you are dealing with squares, you could reduce it to one value:
Of course, if you are binding to a view-model, you could also drive the dimensions through binding.