diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ToggleSwitchPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ToggleSwitchPage.xaml index 8b8a77998..f29b73461 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ToggleSwitchPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ToggleSwitchPage.xaml @@ -19,7 +19,7 @@ Foreground="{DynamicResource TextFillColorPrimaryBrush}" mc:Ignorable="d"> - + - + + + + + + + diff --git a/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs b/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs index 7d6971283..0bb36e7ec 100644 --- a/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs +++ b/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs @@ -3,6 +3,8 @@ // Copyright (C) Leszek Pomianowski and WPF UI Contributors. // All Rights Reserved. +using System.Windows; + namespace Wpf.Ui.Controls; /// @@ -26,6 +28,17 @@ public class ToggleSwitch : System.Windows.Controls.Primitives.ToggleButton new PropertyMetadata(null) ); + /// Identifies the dependency property. + public static readonly DependencyProperty LabelPositionProperty = DependencyProperty.Register( + nameof(LabelPosition), + typeof(ElementPlacement), + typeof(ToggleSwitch), + new FrameworkPropertyMetadata( + ElementPlacement.Right, + FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure + ) + ); + /// /// Gets or sets the content that should be displayed when the is in the "Off" state. /// @@ -45,4 +58,15 @@ public object? OnContent get => GetValue(OnContentProperty); set => SetValue(OnContentProperty, value); } + + /// + /// Gets or sets the position of the label content relative to the toggle switch. + /// + [System.ComponentModel.Bindable(true)] + [System.ComponentModel.Category("Layout")] + public ElementPlacement LabelPosition + { + get => (ElementPlacement)GetValue(LabelPositionProperty); + set => SetValue(LabelPositionProperty, value); + } } diff --git a/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.xaml b/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.xaml index 93ed88c2d..3edc5176b 100644 --- a/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.xaml +++ b/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.xaml @@ -32,6 +32,7 @@ + @@ -43,10 +44,11 @@ - - + + @@ -113,6 +115,16 @@ TextElement.Foreground="{TemplateBinding Foreground}" /> + + + + + + + + + +