Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e9927d5
Create GradientSlider component
Avid29 Jan 8, 2026
2c608e4
Cut template code to basics
Avid29 Jan 8, 2026
1028e20
Added thumb and background population
Avid29 Jan 8, 2026
a1f814f
Styled GradientSliderThumb and added dragging events
Avid29 Jan 8, 2026
b6cb853
Added comments to GradientSlider public members
Avid29 Jan 8, 2026
3fe66b5
GradientSlider thumb drag handling
Avid29 Jan 8, 2026
f3552f4
Refined event subscriptions
Avid29 Jan 8, 2026
219be4c
Added color selection flyout to GradientSliderThumb
Avid29 Jan 8, 2026
3f01d0a
Applied XAML styling
Avid29 Jan 8, 2026
9b7756a
Set explicitly MUXC ColorPicker
Avid29 Jan 8, 2026
22871b7
Fixed Rectangle namespace in WinUI2
Avid29 Jan 9, 2026
fb8175a
Changed GradientSliderThumb to use explicit MUXC for ColorChangedEven…
Avid29 Jan 10, 2026
3c8cfdc
Merge branch 'main' into gradient_slider
Avid29 Jan 10, 2026
ecc79f2
Update components/GradientSlider/src/GradientSlider.cs
Avid29 Jan 10, 2026
3a68bb0
Added placeholder thumb for add position indicator
Avid29 Jan 10, 2026
ca021d1
XAML Styles
Avid29 Jan 10, 2026
29246b4
Added disabled regions for the placeholder thumb
Avid29 Jan 10, 2026
a9ee9af
Add stop on pointer press
Avid29 Jan 10, 2026
bfd18cf
Thumb drag-on-creation for GradientSlider
Avid29 Jan 10, 2026
633a05f
XAML
Avid29 Jan 10, 2026
9e0f37c
Changed default value of GradientStops
Avid29 Jan 10, 2026
60108d4
Added property to enabled/disable adding gradient stops
Avid29 Jan 10, 2026
a1307b8
Added FlowDirection override on default GradientSliderStyle
Avid29 Jan 10, 2026
4d7e543
Do the thing (XAML Styles)
Avid29 Jan 10, 2026
aa83779
Fixed Colors namespace in WinUI2
Avid29 Jan 10, 2026
b40b727
Changed GradientSlider to track position as Point with Y axis
Avid29 Jan 14, 2026
11bec84
Added Keydown adjustments to GradientSlider
Avid29 Jan 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions components/GradientSlider/OpenSolution.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@ECHO OFF

powershell ..\..\tooling\ProjectHeads\GenerateSingleSampleHeads.ps1 -componentPath %CD% %*
Binary file added components/GradientSlider/samples/Assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions components/GradientSlider/samples/Dependencies.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
WinUI 2 under UWP uses TargetFramework uap10.0.*
WinUI 3 under WinAppSdk uses TargetFramework net6.0-windows10.*
However, under Uno-powered platforms, both WinUI 2 and 3 can share the same TargetFramework.

MSBuild doesn't play nicely with this out of the box, so we've made it easy for you.

For .NET Standard packages, you can use the Nuget Package Manager in Visual Studio.
For UWP / WinAppSDK / Uno packages, place the package references here.
-->
<Project>
<!-- WinUI 2 / UWP -->
<ItemGroup Condition="'$(IsUwp)' == 'true'">
<!-- <PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.2"/> -->
</ItemGroup>

<!-- WinUI 2 / Uno -->
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '2'">
<!-- <PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.11"/> -->
</ItemGroup>

<!-- WinUI 3 / WinAppSdk -->
<ItemGroup Condition="'$(IsWinAppSdk)' == 'true'">
<!-- <PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.2"/> -->
</ItemGroup>

<!-- WinUI 3 / Uno -->
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '3'">
<!-- <PackageReference Include="Uno.CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.100-dev.15.g12261e2626"/> -->
</ItemGroup>
</Project>
15 changes: 15 additions & 0 deletions components/GradientSlider/samples/GradientSlider.Samples.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" Condition="Exists('$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))')" />

<PropertyGroup>
<ToolkitComponentName>GradientSlider</ToolkitComponentName>
</PropertyGroup>

<!-- Sets this up as a toolkit component's sample project -->
<Import Project="$(ToolingDirectory)\ToolkitComponent.SampleProject.props" />
<ItemGroup>
<Compile Update="GradientSliderSample.xaml.cs">
<DependentUpon>GradientSliderSample.xaml</DependentUpon>
</Compile>
</ItemGroup>
</Project>
25 changes: 25 additions & 0 deletions components/GradientSlider/samples/GradientSlider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: GradientSlider
author: githubaccount
description: TODO: Your experiment's description here
keywords: GradientSlider, Control, Layout
dev_langs:
- csharp
category: Controls
subcategory: Layout
discussion-id: 0
issue-id: 0
icon: assets/icon.png
---

<!-- To know about all the available Markdown syntax, Check out https://docs.microsoft.com/contribute/markdown-reference -->
<!-- Ensure you remove all comments before submission, to ensure that there are no formatting issues when displaying this page. -->
<!-- It is recommended to check how the Documentation will look in the sample app, before Merging a PR -->
<!-- **Note:** All links to other docs.microsoft.com pages should be relative without locale, i.e. for the one above would be /contribute/markdown-reference -->
<!-- Included images should be optimized for size and not include any Intellectual Property references. -->

<!-- Be sure to update the discussion/issue numbers above with your Labs discussion/issue id numbers in order for UI links to them from the sample app to work. -->

# GradientSlider

> [!SAMPLE GradientSliderSample]
23 changes: 23 additions & 0 deletions components/GradientSlider/samples/GradientSliderSample.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE file in the project root for more information. -->
<Page x:Class="GradientSliderExperiment.Samples.GradientSliderSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:CommunityToolkit.WinUI.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:GradientSliderExperiment.Samples"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<StackPanel Spacing="16">
<controls:GradientSlider IsAddStopsEnabled="{x:Bind CanAddStops, Mode=OneWay}">
<controls:GradientSlider.GradientStops>
<GradientStopCollection>
<GradientStop Offset="0" Color="#FF0000" />
<GradientStop Offset="0.3" Color="#00FF00" />
<GradientStop Offset="0.66" Color="#0000FF" />
<GradientStop Offset="1" Color="#FF0000" />
</GradientStopCollection>
</controls:GradientSlider.GradientStops>
Comment on lines +13 to +20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the developer doesn't specify any stops at the start? Could be good to have another example where it's bound to a collection (to show binding) but that collection is also empty to start?

</controls:GradientSlider>
</StackPanel>
</Page>
21 changes: 21 additions & 0 deletions components/GradientSlider/samples/GradientSliderSample.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using CommunityToolkit.WinUI.Controls;

namespace GradientSliderExperiment.Samples;

/// <summary>
/// An example sample page of a custom control inheriting from Panel.
/// </summary>

[ToolkitSample(id: nameof(GradientSliderSample), "Custom control", description: $"A sample for showing how to create and use a {nameof(GradientSlider)} custom control.")]
[ToolkitSampleBoolOption("CanAddStops", true, Title = nameof(GradientSlider.IsAddStopsEnabled))]
public sealed partial class GradientSliderSample : Page
{
public GradientSliderSample()
{
this.InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" Condition="Exists('$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))')" />

<PropertyGroup>
<ToolkitComponentName>GradientSlider</ToolkitComponentName>
<Description>This package contains GradientSlider.</Description>

<!-- Rns suffix is required for namespaces shared across projects. See https://github.com/CommunityToolkit/Labs-Windows/issues/152 -->
<RootNamespace>CommunityToolkit.WinUI.Controls.GradientSliderRns</RootNamespace>
</PropertyGroup>

<!-- Sets this up as a toolkit component's source project -->
<Import Project="$(ToolingDirectory)\ToolkitComponent.SourceProject.props" />
</Project>
Comment on lines +13 to +14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Import Project="$(ToolingDirectory)\ToolkitComponent.SourceProject.props" />
</Project>
<Import Project="$(ToolingDirectory)\ToolkitComponent.SourceProject.props" />
<PropertyGroup>
<PackageId>$(PackageIdPrefix).$(PackageIdVariant).Controls.$(ToolkitComponentName)</PackageId>
</PropertyGroup>
</Project>

We need the Controls added to the package, right @Arlodotexe? (Remind me again why we don't grab this from the csproj name?)

31 changes: 31 additions & 0 deletions components/GradientSlider/src/Dependencies.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
WinUI 2 under UWP uses TargetFramework uap10.0.*
WinUI 3 under WinAppSdk uses TargetFramework net6.0-windows10.*
However, under Uno-powered platforms, both WinUI 2 and 3 can share the same TargetFramework.

MSBuild doesn't play nicely with this out of the box, so we've made it easy for you.

For .NET Standard packages, you can use the Nuget Package Manager in Visual Studio.
For UWP / WinAppSDK / Uno packages, place the package references here.
-->
<Project>
<!-- WinUI 2 / UWP -->
<ItemGroup Condition="'$(IsUwp)' == 'true'">
<!-- <PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.2"/> -->
</ItemGroup>

<!-- WinUI 2 / Uno -->
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '2'">
<!-- <PackageReference Include="Uno.Microsoft.Toolkit.Uwp.UI.Controls.Primitives" Version="7.1.11"/> -->
</ItemGroup>

<!-- WinUI 3 / WinAppSdk -->
<ItemGroup Condition="'$(IsWinAppSdk)' == 'true'">
<!-- <PackageReference Include="CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.2"/> -->
</ItemGroup>

<!-- WinUI 3 / Uno -->
<ItemGroup Condition="'$(IsUno)' == 'true' AND '$(WinUIMajorVersion)' == '3'">
<!-- <PackageReference Include="Uno.CommunityToolkit.WinUI.UI.Controls.Primitives" Version="7.1.100-dev.15.g12261e2626"/> -->
</ItemGroup>
</Project>
49 changes: 49 additions & 0 deletions components/GradientSlider/src/GradientSlider.Events.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace CommunityToolkit.WinUI.Controls;

public partial class GradientSlider
{
/// <summary>
/// Event raised when a thumb starts being dragged.
/// </summary>
public event DragStartedEventHandler? ThumbDragStarted;

/// <summary>
/// Event raised when a thumb ends being dragged.
/// </summary>
public event DragCompletedEventHandler? ThumbDragCompleted;

/// <summary>
/// Event raised when the gradient's value changes.
/// </summary>
public event EventHandler? ValueChanged;

/// <summary>
/// Called before the <see cref="ThumbDragStarted"/> event occurs.
/// </summary>
/// <param name="e">Event data for the event.</param>
protected virtual void OnThumbDragStarted(DragStartedEventArgs e)
{
ThumbDragStarted?.Invoke(this, e);
}

/// <summary>
/// Called before the <see cref="ThumbDragCompleted"/> event occurs.
/// </summary>
/// <param name="e">Event data for the event.</param>
protected virtual void OnThumbDragCompleted(DragCompletedEventArgs e)
{
ThumbDragCompleted?.Invoke(this, e);
}

/// <summary>
/// Called before the <see cref="ValueChanged"/> event occurs.
/// </summary>
protected virtual void OnValueChanged()
{
ValueChanged?.Invoke(this, EventArgs.Empty);
}
}
Loading
Loading