给定以下的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>
...
canvas的背景被忽略了,相反路径是可见的,而且背景是透明的,这是因为PasswordBox后面的表格。那么我应该在哪里设置“背景背景”?
WindowBrush
会使它与背景窗体相同。你确定它不只是相同的颜色吗?你尝试过像Background="Red"
这样的东西吗? - JayPath.Fill
上怎么样? - Jay