0
我正在用XAML和C#编写商店应用程序。我想使用Border和ViewBox。我有边框样式,所以我不必多次设置属性。我将BorderThickness设置为2,并将颜色设置为白色,但这会在我的Viewbox中导致问题。视框和边框
这是XAML:
<Viewbox Grid.Row="1" Stretch="Uniform">
<Grid Width="600" Height="600">
<Grid.Resources>
<Style TargetType="Border">
<Setter Property="BorderBrush" Value="White" />
<Setter Property="BorderThickness" Value="2" />
</Style>
<Style TargetType="Grid">
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="Width" Value="150" />
<Setter Property="Height" Value="150" />
</Style>
</Grid.Resources>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Grid>
<Border>
<Viewbox>
<TextBlock Text="T" />
</Viewbox>
</Border>
</Grid>
这样做的结果是:
的问题是围绕着字母 “T” 缩放边框。
我不想删除Grid.Resources中Border的上述样式。我只找到一个解决方案至今...
<Viewbox>
<Viewbox.Resources>
<Style TargetType="Border">
<Setter Property="BorderBrush" Value="White" />
<Setter Property="BorderThickness" Value="0" />
</Style>
</Viewbox.Resources>
<TextBlock Text="T" />
...你会给出正确的结果:
,但我不希望把每个ViewBoxes后这些行,因为会有很多。 我也尝试过创建一个组件,这个默认的“资源”是零厚边框,但是缩放比例不好。
所以我的问题是如何删除该边框?
该程序没有适用于商店应用程序。 :( – 2013-05-07 10:30:27