-
Notifications
You must be signed in to change notification settings - Fork 123
[Converters] Adding updated samples #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
components/Converters/samples/BoolNegationConverterSample.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
16
components/Converters/samples/BoolNegationConverterSample.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
22
components/Converters/samples/BoolToObjectConverterSample.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
16
components/Converters/samples/BoolToObjectConverterSample.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
40
components/Converters/samples/BoolToVisibilityConverterSample.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
16 changes: 16 additions & 0 deletions
16
components/Converters/samples/BoolToVisibilityConverterSample.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| } | ||
| } |
26 changes: 26 additions & 0 deletions
26
components/Converters/samples/CollectionVisibilityConverterSample.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
16 changes: 16 additions & 0 deletions
16
components/Converters/samples/CollectionVisibilityConverterSample.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
components/Converters/samples/ColorToDisplayNameConverterSample.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
14 changes: 14 additions & 0 deletions
14
components/Converters/samples/ColorToDisplayNameConverterSample.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.