1
有人可以解釋我對「矩形拉伸」屬性的誤解:將其設置爲「無」時?根據MSDN,此值的定義是「內容保留其原始大小」。看看下面的代碼。當我在第四個矩形上設置Stretch = NONE時,它消失。矩形拉伸屬性行爲
<Grid Margin="20">
<Rectangle Height="Auto" Width="2" HorizontalAlignment="Left" VerticalAlignment="Stretch" Fill="Black"/>
<Rectangle Height="2" Width="10" HorizontalAlignment="Left" VerticalAlignment="Top" Fill="Black"/>
<Rectangle Height="2" Width="10" HorizontalAlignment="Left" VerticalAlignment="Bottom" Fill="Black"/>
<Rectangle Stretch="None" Name="Right" Height="Auto" Width="2" HorizontalAlignment="Right" VerticalAlignment="Stretch" Fill="Black"/>
<Rectangle Height="2" Width="10" HorizontalAlignment="Right" VerticalAlignment="Top" Fill="Black"/>
<Rectangle Height="2" Width="10" HorizontalAlignment="Right" VerticalAlignment="Bottom" Fill="Black"/>
</Grid>
爲什麼會發生這種情況?此代碼是我在自定義圖表上使用的分頁控件的摘錄。我將分頁控件包裝在ViewBox中以允許自動調整大小,但我不希望邊界標記調整大小(上面的示例是頁面邊框標記的樣子)。