我想在下面制作一个像图片一样的wpf控件 circle with hole
我在xaml
中使用此代码制作带孔的圆圈<Ellipse Width="350" Height="350" StrokeThickness="80" Fill="Transparent">
<Ellipse.Stroke>
<LinearGradientBrush>
<GradientStop Offset="0" Color="Gray"/>
<GradientStop Offset="1" Color="Gray"/>
</LinearGradientBrush>
</Ellipse.Stroke>
</Ellipse>
但我不知道怎么把图标放进去 有没有类似的组件? 我希望这项工作在不同的分辨率上,这个图标的数量是动态的 所以另一个问题是如何扩展它以增加更多的图标 日Thnx
答案 0 :(得分:0)
试试这个:
<Border CornerRadius="1000"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="DarkGray">
<Grid>
<Border x:Name="SomeIcon"
Width="50"
Height="50"
Margin="10"
Background="Black"
HorizontalAlignment="Left" />
<Border HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Margin="80"
CornerRadius="3000"
Background="White"/>
</Grid>
</Border>
答案 1 :(得分:0)
这将有用。替换图像标记中图标的来源和路径
<Border CornerRadius="1000" HorizontalAlignment="Center" VerticalAlignment="Center"
Background="DarkGray" Height="500" Width="500">
<Grid>
<Image x:Name="Icon" Source="C:\Users\Administrator\Pictures\user-thumbnail.png"
Height="70" Width="70" HorizontalAlignment="Left" Margin="20"/>
<Border HorizontalAlignment="Center" VerticalAlignment="Center"
Height="300" Width="300" CornerRadius="150" Background="White"/>
</Grid>
</Border>