diff --git a/samples/ControlCatalog/MainView.xaml b/samples/ControlCatalog/MainView.xaml index af2d093bc7..fef68bb5f5 100644 --- a/samples/ControlCatalog/MainView.xaml +++ b/samples/ControlCatalog/MainView.xaml @@ -57,6 +57,7 @@ + diff --git a/samples/ControlCatalog/Pages/ToggleSwitchPage.xaml b/samples/ControlCatalog/Pages/ToggleSwitchPage.xaml new file mode 100644 index 0000000000..161ee2ee16 --- /dev/null +++ b/samples/ControlCatalog/Pages/ToggleSwitchPage.xaml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/ControlCatalog/Pages/ToggleSwitchPage.xaml.cs b/samples/ControlCatalog/Pages/ToggleSwitchPage.xaml.cs new file mode 100644 index 0000000000..66f7d14c7f --- /dev/null +++ b/samples/ControlCatalog/Pages/ToggleSwitchPage.xaml.cs @@ -0,0 +1,19 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace ControlCatalog.Pages +{ + public class ToggleSwitchPage : UserControl + { + public ToggleSwitchPage() + { + this.InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + } +} diff --git a/src/Avalonia.Controls/ToggleSwitch.cs b/src/Avalonia.Controls/ToggleSwitch.cs index 6c6426a31d..4b42c574cf 100644 --- a/src/Avalonia.Controls/ToggleSwitch.cs +++ b/src/Avalonia.Controls/ToggleSwitch.cs @@ -1,4 +1,5 @@ -using Avalonia.Controls.Primitives; +using Avalonia.Controls.Presenters; +using Avalonia.Controls.Primitives; using Avalonia.Controls.Templates; using Avalonia.LogicalTree; @@ -57,6 +58,18 @@ namespace Avalonia.Controls set { SetValue(OffContentProperty, value); } } + public IContentPresenter OffContentPresenter + { + get; + private set; + } + + public IContentPresenter OnContentPresenter + { + get; + private set; + } + /// /// Gets or Sets the used to display the . /// @@ -100,6 +113,24 @@ namespace Avalonia.Controls LogicalChildren.Add(newChild); } } + + protected override bool RegisterContentPresenter(IContentPresenter presenter) + { + var result = base.RegisterContentPresenter(presenter); + + if (presenter.Name == "Part_OnContentPresenter") + { + OnContentPresenter = presenter; + result = true; + } + else if (presenter.Name == "PART_OffContentPresenter") + { + OffContentPresenter = presenter; + result = true; + } + + return result; + } } } diff --git a/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj b/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj index 3c3e14010d..a4eab83e4a 100644 --- a/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj +++ b/src/Avalonia.Themes.Fluent/Avalonia.Themes.Fluent.csproj @@ -19,4 +19,4 @@ - + \ No newline at end of file