Can we able to modify the design of toggle switch in maui ?

Sowndarrajan Vijayaragavan 450 Reputation points
2023-05-04T04:52:36.3566667+00:00

Need to increase the Black dot size

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
4,000 questions
{count} vote

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 49,211 Reputation points Microsoft External Staff
    2023-05-05T02:53:50.0833333+00:00

    Hello,

    In order to increase the circle size, you could copy default style for ToggleSwitch from the path C:\Program Files (x86)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP\Generic\generic.xaml into Your_MAUI_Project\Platforms\Windows\App.xaml, such as the following code:

    <maui:MauiWinUIApplication  
           ...>  
         
           <maui:MauiWinUIApplication.Resources>  
               <!-- Default style for Windows.UI.Xaml.Controls.ToggleSwitch --> from generic.xaml file.  
           </maui:MauiWinUIApplication.Resources>  
         
    </maui:MauiWinUIApplication>  
    

    Then, you could modify the following two properties to increase the circle size:

    <Ellipse x:Name="SwitchKnobOn" 
    	Fill="{ThemeResource ToggleSwitchKnobFillOn}"
    	Width="10" -> Width="15"
    	Height="10" -> Height="15"
    	Opacity="0" />
    <Ellipse x:Name="SwitchKnobOff"
    	Fill="{ThemeResource ToggleSwitchKnobFillOff}"
    	Width="10" -> Width="15"
    	Height="10" /> -> Height="15"
    

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.