Skip to content

Commit 854d13b

Browse files
committed
Added enum sample binding for Marquee Sample
1 parent b8a43c5 commit 854d13b

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
<!-- 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. -->
1+
<!-- 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. -->
22
<Page x:Class="MarqueeTextExperiment.Samples.MarqueeTextSample"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:labs="using:CommunityToolkit.Labs.WinUI.MarqueeTextRns"
7+
xmlns:local="MarqueeTextExperiment.Samples"
78
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
89
mc:Ignorable="d">
910

1011
<StackPanel Padding="16">
11-
<labs:MarqueeText Behavior="Looping"
12-
Direction="Left"
12+
<labs:MarqueeText Behavior="{x:Bind ConvertStringToMarqueeBehavior(MQBehavior), Mode=OneWay}"
13+
Direction="{x:Bind ConvertStringToMarqueeDirection(MQDirection), Mode=OneWay}"
1314
FontSize="18"
14-
RepeatBehavior="{x:Bind MarqueeRepeat, Mode=OneWay}"
15-
Speed="{x:Bind MarqueeSpeed, Mode=OneWay}"
15+
RepeatBehavior="Forever"
16+
Speed="{x:Bind MQSpeed, Mode=OneWay}"
1617
Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." />
1718
</StackPanel>
1819
</Page>

components/MarqueeText/samples/MarqueeTextSample.xaml.cs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,41 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using CommunityToolkit.Labs.WinUI.MarqueeTextRns;
6+
57
namespace MarqueeTextExperiment.Samples;
68
[ToolkitSample(id: nameof(MarqueeTextSample), "MarqueeText", description: "A control for scrolling text in a marquee fashion.")]
7-
[ToolkitSampleMultiChoiceOption("MarqueeSpeed", "Speed", "Slow : 64", "Medium : 96", "Fast : 128")]
8-
//[ToolkitSampleMultiChoiceOption("MarqueeMode", "Mode", "Ticker", "Looping", "Bouncing")]
9-
//[ToolkitSampleMultiChoiceOption("MarqueeDirection", "Direction", "Left", "Right", "Up", "Down")]
10-
[ToolkitSampleMultiChoiceOption("MarqueeRepeat", "Repeat", "Forever", "1x", "2x")]
9+
[ToolkitSampleNumericOption("MQSpeed", initial: 96, min: 48, max: 196, step: 1, Title = "Speed")]
10+
[ToolkitSampleMultiChoiceOption("MQDirection", "Left", "Right", "Up", "Down", Title = "Marquee Direction")]
11+
//[ToolkitSampleMultiChoiceOption("MarqueeRepeat", "Repeat", "Forever", "1x", "2x")]
12+
#if !HAS_UNO
13+
[ToolkitSampleMultiChoiceOption("MQBehavior", "Ticker", "Looping", "Bouncing", Title = "Marquee Behavior")]
14+
#else
15+
[ToolkitSampleMultiChoiceOption("MQBehavior", "Ticker", "Looping", Title = "Marquee Behavior")]
16+
#endif
1117
public sealed partial class MarqueeTextSample : Page
1218
{
1319
public MarqueeTextSample()
1420
{
1521
this.InitializeComponent();
1622
}
23+
24+
private MarqueeBehavior ConvertStringToMarqueeBehavior(string str) => str switch
25+
{
26+
"Looping" => MarqueeBehavior.Looping,
27+
"Ticker" => MarqueeBehavior.Ticker,
28+
#if !HAS_UNO
29+
"Bouncing" => MarqueeBehavior.Bouncing,
30+
#endif
31+
_ => throw new System.NotImplementedException(),
32+
};
33+
34+
private MarqueeDirection ConvertStringToMarqueeDirection(string str) => str switch
35+
{
36+
"Left" => MarqueeDirection.Left,
37+
"Up" => MarqueeDirection.Up,
38+
"Right" => MarqueeDirection.Right,
39+
"Down" => MarqueeDirection.Down,
40+
_ => throw new System.NotImplementedException(),
41+
};
1742
}

0 commit comments

Comments
 (0)