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