WPF RING Button

GuoLearn 251 Reputation points
2022-06-17T01:46:23.45+00:00

Could you tell me how to Make a Ring Button that can been split in any angle And The selection unit have a Image and textblock on the center,please?

212282-cc.png

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,681 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
768 questions
0 comments No comments
{count} votes

Accepted answer
  1. Hui Liu-MSFT 40,786 Reputation points Microsoft Vendor
    2022-06-17T06:12:41.357+00:00

    Hi,@GuoLearn . Welcome Microsoft Q&A.
    You could refer to the following code to set the Button.

    Xaml:

    <StackPanel>  
    
            <Button x:Name="btn"  >  
                <Button.Template>  
                    <ControlTemplate>  
    
                        <Canvas Margin="100">  
                            <Path Stroke="LightBlue" StrokeThickness="5">  
                                <Path.Data>  
                                    <PathGeometry>  
                                        <PathFigure StartPoint="0,-50">  
                                            <ArcSegment Point="42.5,-26.2" Size="50,50"   IsLargeArc="False" SweepDirection="Clockwise"/>  
                                        </PathFigure>  
                                        <PathGeometry.Transform>  
                                            <RotateTransform Angle="10"/>  
                                        </PathGeometry.Transform>  
                                    </PathGeometry>  
                                </Path.Data>  
                            </Path>  
                            <Path Stroke="LightPink" StrokeThickness="5">  
                                <Path.Data>  
                                    <PathGeometry>  
                                        <PathFigure StartPoint="0,-50">  
                                            <ArcSegment Point="42.5,-26.2" Size="50,50"   IsLargeArc="False" SweepDirection="Clockwise"/>  
                                        </PathFigure>  
                                        <PathGeometry.Transform>  
                                            <RotateTransform Angle="70"/>  
                                        </PathGeometry.Transform>  
                                    </PathGeometry>  
                                </Path.Data>  
                            </Path>  
    
                            <Path Stroke="LightGreen" StrokeThickness="5">  
                                <Path.Data>  
                                    <PathGeometry>  
                                        <PathFigure StartPoint="0,-50">  
                                            <ArcSegment Point="42.5,-26.2" Size="50,50"   IsLargeArc="False" SweepDirection="Clockwise"/>  
                                        </PathFigure>  
                                        <PathGeometry.Transform>  
                                            <RotateTransform Angle="130"/>  
                                        </PathGeometry.Transform>  
                                    </PathGeometry>  
                                </Path.Data>  
                            </Path>  
                            <Path Stroke="LightCoral" StrokeThickness="5">  
                                <Path.Data>  
                                    <PathGeometry>  
                                        <PathFigure StartPoint="0,-50">  
                                            <ArcSegment Point="42.5,-26.2" Size="50,50"   IsLargeArc="False" SweepDirection="Clockwise"/>  
                                        </PathFigure>  
                                        <PathGeometry.Transform>  
                                            <RotateTransform Angle="190"/>  
                                        </PathGeometry.Transform>  
                                    </PathGeometry>  
                                </Path.Data>  
                            </Path>  
                            <Path Stroke="LightGray" StrokeThickness="5">  
                                <Path.Data>  
                                    <PathGeometry>  
                                        <PathFigure StartPoint="0,-50">  
                                            <ArcSegment Point="42.5,-26.2" Size="50,50"   IsLargeArc="False" SweepDirection="Clockwise"/>  
                                        </PathFigure>  
                                        <PathGeometry.Transform>  
                                            <RotateTransform Angle="250"/>  
                                        </PathGeometry.Transform>  
                                    </PathGeometry>  
                                </Path.Data>  
                            </Path>  
                            <Path Stroke="LightSalmon" StrokeThickness="5">  
                                <Path.Data>  
                                    <PathGeometry>  
                                        <PathFigure StartPoint="0,-50">  
                                            <ArcSegment Point="42.5,-26.2" Size="50,50"   IsLargeArc="False" SweepDirection="Clockwise"/>  
                                        </PathFigure>  
                                        <PathGeometry.Transform>  
                                            <RotateTransform Angle="310"/>  
                                        </PathGeometry.Transform>  
                                    </PathGeometry>  
                                </Path.Data>  
                            </Path>  
                            <StackPanel Margin="-20,-20">  
                                <TextBlock  Text="hello" Width="30" Height="20" FontSize="10" Background="AliceBlue"/>  
                                <Image Source="images.jpg" Width="45" />  
                            </StackPanel>  
    
                        </Canvas>  
    
                    </ControlTemplate>  
                </Button.Template>  
            </Button>  
        </StackPanel>  
    

    The result:

    212279-image.png


    If the response is helpful, please click "Accept Answer" and upvote it.
     Note: Please follow the steps in our [documentation][5] to enable e-mail notifications if you want to receive the related email notification for this thread. 

    [5]: https://learn.microsoft.com/en-us/answers/articles/67444/email-notifications.html


0 additional answers

Sort by: Most helpful