我已經在XAML中創建了Ellipse。基於百分比填充橢圓
下面是代碼:
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Ellipse Width="400" Stroke="DodgerBlue" Height="400" StrokeThickness="75" Fill="Transparent">
</Ellipse>
</Grid>
說的橢圓是100%,如果20%的藍顏色應填寫只能做到這一點,並顯示橢圓形的中心(空區)的百分比文本。
編輯
我添加文本在中心顯示。
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Ellipse Width="400" Stroke="DodgerBlue" Height="400" StrokeThickness="75" Fill="Transparent">
</Ellipse>
<TextBlock VerticalAlignment="Center"
HorizontalAlignment="Center"
Text="20"
FontSize="125"/>
</Grid>
EDIT 2
這裏是怎麼它看起來像我試圖acheive:
這裏的橙色與20%填充。
是否要填充藍色邊框或內部 - 當前透明的內容? – Herdo
@Herdo現在顯示完全填滿的藍色,只應該填一下如果其中有20個(全部爲橢圓),也就是說如果80%則填充80%橢圓,內部空應該是 – Goofy
您可以設置百分比在TextBlock.Text屬性中(如果你使用的是mvvm設計模式,你可以使用綁定),對於Ellipse.StrokeThickness則使用TextBlock。文本屬性(或綁定),並應用轉換器將百分比轉換爲「StrokeThickness」的值。 – Herdo