From c1081cc3bf8006a95e79fac02e82382a1cad69b0 Mon Sep 17 00:00:00 2001 From: zh3305 Date: Sun, 23 Apr 2023 11:42:51 +0800 Subject: [PATCH 1/2] update ToggleSwitch add OffContent OnContent --- .../Pages/BasicInput/ToggleSwitchPage.xaml | 7 ++- src/Wpf.Ui/Controls/ToggleSwitch.cs | 20 +++++++ src/Wpf.Ui/Styles/Controls/ToggleSwitch.xaml | 52 +++++++++++++++++-- 3 files changed, 71 insertions(+), 8 deletions(-) diff --git a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ToggleSwitchPage.xaml b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ToggleSwitchPage.xaml index db9003333..014b529bc 100644 --- a/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ToggleSwitchPage.xaml +++ b/src/Wpf.Ui.Gallery/Views/Pages/BasicInput/ToggleSwitchPage.xaml @@ -37,7 +37,7 @@ @@ -46,8 +46,7 @@ - \ No newline at end of file + diff --git a/src/Wpf.Ui/Controls/ToggleSwitch.cs b/src/Wpf.Ui/Controls/ToggleSwitch.cs index 01f477248..6470541d3 100644 --- a/src/Wpf.Ui/Controls/ToggleSwitch.cs +++ b/src/Wpf.Ui/Controls/ToggleSwitch.cs @@ -5,6 +5,7 @@ using System.ComponentModel; using System.Drawing; +using System.Windows; namespace Wpf.Ui.Controls; @@ -15,4 +16,23 @@ namespace Wpf.Ui.Controls; [ToolboxBitmap(typeof(ToggleSwitch), "ToggleSwitch.bmp")] public class ToggleSwitch : System.Windows.Controls.Primitives.ToggleButton { + public static readonly DependencyProperty OffContentProperty = DependencyProperty.Register( + "OffContent", typeof(object), typeof(ToggleSwitch), new PropertyMetadata(null)); + + [Bindable(true)] + public object OffContent + { + get => GetValue(OffContentProperty); + set => SetValue(OffContentProperty, value); + } + + public static readonly DependencyProperty OnContentProperty = DependencyProperty.Register( + "OnContent", typeof(object), typeof(ToggleSwitch), new PropertyMetadata(null)); + + [Bindable(true)] + public object OnContent + { + get => GetValue(OnContentProperty); + set => SetValue(OnContentProperty, value); + } } diff --git a/src/Wpf.Ui/Styles/Controls/ToggleSwitch.xaml b/src/Wpf.Ui/Styles/Controls/ToggleSwitch.xaml index 16add91d3..267ff6c66 100644 --- a/src/Wpf.Ui/Styles/Controls/ToggleSwitch.xaml +++ b/src/Wpf.Ui/Styles/Controls/ToggleSwitch.xaml @@ -127,12 +127,24 @@ TextElement.Foreground="{TemplateBinding Foreground}" /> - + + + + + + - - + + + + + + + + - + + @@ -219,6 +231,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 554955ef1d8f24186912f855170809f595d4f6dc Mon Sep 17 00:00:00 2001 From: pomian <13592821+pomianowski@users.noreply.github.com> Date: Sun, 22 Oct 2023 15:34:11 +0200 Subject: [PATCH 2/2] Disable ToolboxItem features --- src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs b/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs index aaaa55cc3..f0c10ff23 100644 --- a/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs +++ b/src/Wpf.Ui/Controls/ToggleSwitch/ToggleSwitch.cs @@ -12,8 +12,8 @@ namespace Wpf.Ui.Controls; /// /// Use to present users with two mutally exclusive options (like on/off). /// -[ToolboxItem(true)] -[ToolboxBitmap(typeof(ToggleSwitch), "ToggleSwitch.bmp")] +// [ToolboxItem(true)] +// [ToolboxBitmap(typeof(ToggleSwitch), "ToggleSwitch.bmp")] public class ToggleSwitch : System.Windows.Controls.Primitives.ToggleButton { ///