Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions components/Converters/samples/BoolNegationConverterSample.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- 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="ConvertersExperiment.Samples.BoolNegationConverterSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:ConvertersExperiment.Samples"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
</Page.Resources>

<Button Content="Inverted value set as IsEnabled"
IsEnabled="{x:Bind MyBooleanValue, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}" />
</Page>
16 changes: 16 additions & 0 deletions components/Converters/samples/BoolNegationConverterSample.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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 ConvertersExperiment.Samples;

[ToolkitSampleBoolOption("MyBooleanValue", true, Title = "Original value")]

[ToolkitSample(id: nameof(BoolNegationConverterSample), "BoolNegationConverter", description: $"A sample for showing how to use the BoolNegationConverter.")]
public sealed partial class BoolNegationConverterSample : Page
{
public BoolNegationConverterSample()
{
this.InitializeComponent();
}
}
22 changes: 22 additions & 0 deletions components/Converters/samples/BoolToObjectConverterSample.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- 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="ConvertersExperiment.Samples.BoolToObjectConverterSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:ConvertersExperiment.Samples"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<converters:BoolToObjectConverter x:Key="BoolToObjectConverter"
FalseValue="{ThemeResource ControlStrongFillColorDefaultBrush}"
TrueValue="{ThemeResource AccentFillColorDefaultBrush}" />
</Page.Resources>

<Border Width="64"
Height="64"
HorizontalAlignment="Left"
Background="{x:Bind MyBooleanValue, Mode=OneWay, Converter={StaticResource BoolToObjectConverter}}"
CornerRadius="4" />
</Page>
16 changes: 16 additions & 0 deletions components/Converters/samples/BoolToObjectConverterSample.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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 ConvertersExperiment.Samples;

[ToolkitSampleBoolOption("MyBooleanValue", false, Title = "Toggle to change colors")]

[ToolkitSample(id: nameof(BoolToObjectConverterSample), "BoolToObjectConverter", description: $"A sample for showing how to use the BoolToObjectConverter.")]
public sealed partial class BoolToObjectConverterSample : Page
{
public BoolToObjectConverterSample()
{
this.InitializeComponent();
}
}
40 changes: 40 additions & 0 deletions components/Converters/samples/BoolToVisibilityConverterSample.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!-- 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="ConvertersExperiment.Samples.BoolToVisibilityConverterSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:ConvertersExperiment.Samples"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Page.Resources>
<Style x:Key="PlaceholderCardStyle"
TargetType="Border">
<Style.Setters>
<Setter Property="Width" Value="64" />
<Setter Property="Height" Value="64" />
<Setter Property="Background" Value="{ThemeResource CardBackgroundFillColorDefaultBrush}" />
<Setter Property="BorderBrush" Value="{ThemeResource CardStrokeColorDefaultBrush}" />
<Setter Property="BorderThickness" Value="1" />
</Style.Setters>
</Style>

<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
</Page.Resources>

<StackPanel Orientation="Horizontal"
Spacing="12">
<Border Style="{StaticResource PlaceholderCardStyle}">
<Image HorizontalAlignment="Left"
Source="/Assets/Converters.png"
Visibility="{x:Bind MyBooleanValue, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}" />
</Border>

<Border Style="{StaticResource PlaceholderCardStyle}">
<Image HorizontalAlignment="Left"
Source="/Assets/Converters.png"
Visibility="{x:Bind MyBooleanValue, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=True}" />
</Border>
</StackPanel>

</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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 ConvertersExperiment.Samples;

[ToolkitSampleBoolOption("MyBooleanValue", true, Title = "Toggle to show or hide the image")]

[ToolkitSample(id: nameof(BoolToVisibilityConverterSample), "BoolToVisibilityConverter", description: $"A sample for showing how to use the BoolToVisibilityConverter.")]
public sealed partial class BoolToVisibilityConverterSample : Page
{
public BoolToVisibilityConverterSample()
{
this.InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- 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="ConvertersExperiment.Samples.CollectionVisibilityConverterSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:ConvertersExperiment.Samples"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>
<converters:CollectionVisibilityConverter x:Key="CollectionVisibilityConverter" />
</Page.Resources>

<Grid>
<TextBlock HorizontalAlignment="Center"
TextAlignment="Center"
Visibility="{x:Bind EmptyCollection, Mode=OneWay, Converter={StaticResource CollectionVisibilityConverter}, ConverterParameter=True}">
<Run FontWeight="SemiBold"
Text="All done for the day" />
<LineBreak />
<Run Foreground="{ThemeResource TextFillColorSecondaryBrush}"
Text="Enjoy your empty inbox" />
</TextBlock>
</Grid>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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 ConvertersExperiment.Samples;

[ToolkitSample(id: nameof(CollectionVisibilityConverterSample), "CollectionVisibilityConverter", description: $"A sample for showing how to use the CollectionVisibilityConverter.")]
public sealed partial class CollectionVisibilityConverterSample : Page
{
public ObservableCollection<string> EmptyCollection = new();

public CollectionVisibilityConverterSample()
{
this.InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!-- 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="ConvertersExperiment.Samples.ColorToDisplayNameConverterSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:CommunityToolkit.WinUI.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:ConvertersExperiment.Samples"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d">

<Page.Resources>
<converters:ColorToDisplayNameConverter x:Key="ColorToDisplayNameConverter" />
</Page.Resources>

<StackPanel HorizontalAlignment="Left"
Spacing="16">

<ColorPicker x:Name="colorPicker"
Height="64"
VerticalAlignment="Top"
ColorSpectrumShape="Box"
IsAlphaEnabled="False"
IsAlphaSliderVisible="True"
IsAlphaTextInputVisible="True"
IsColorChannelTextInputVisible="False"
IsColorSliderVisible="False"
IsHexInputVisible="False"
IsMoreButtonVisible="False" />
<TextBlock Text="{Binding ElementName=colorPicker, Path=Color, Converter={StaticResource ColorToDisplayNameConverter}}" />
</StackPanel>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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 ConvertersExperiment.Samples;

[ToolkitSample(id: nameof(ColorToDisplayNameConverterSample), "ColorToDisplayNameConverter", description: $"A sample for showing how to use the ColorToDisplayNameConverter.")]
public sealed partial class ColorToDisplayNameConverterSample : Page
{
public ColorToDisplayNameConverterSample()
{
this.InitializeComponent();
}
}
8 changes: 8 additions & 0 deletions components/Converters/samples/Converters.Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@

<!-- Sets this up as a toolkit component's sample project -->
<Import Project="$(ToolingDirectory)\ToolkitComponent.SampleProject.props" />
<ItemGroup>
<None Remove="Assets\Converters.png" />
</ItemGroup>
<ItemGroup>
<UpToDateCheckInput Remove="StringFormatConverterSample.xaml" />
</ItemGroup>
<ItemGroup>
<Content Include="Assets\Converters.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Compile Update="StringFormatConverterSample.xaml.cs">
<DependentUpon>StringFormatConverterSample.xaml</DependentUpon>
Expand Down
Loading