Skip to content

Commit 834531c

Browse files
committed
Added 2 extra commands for each Formatter of TextToolbar.
1 parent bac2461 commit 834531c

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/TextToolbar/TextToolbarPage.xaml.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.Toolkit.Uwp.UI.Controls;
88
using Microsoft.Toolkit.Uwp.UI.Controls.TextToolbarButtons;
99
using Microsoft.Toolkit.Uwp.UI.Controls.TextToolbarFormats.MarkDown;
10+
using Microsoft.Toolkit.Uwp.UI.Controls.TextToolbarFormats.RichText;
1011
using Microsoft.Toolkit.Uwp.UI.Extensions;
1112
using Windows.System;
1213
using Windows.UI.Xaml;
@@ -57,6 +58,16 @@ private void Load()
5758
AddCustomButton();
5859
});
5960

61+
SampleController.Current.RegisterNewCommand("Use RichText Formatter", (sender, args) =>
62+
{
63+
UseRichTextFormatter();
64+
});
65+
66+
SampleController.Current.RegisterNewCommand("Use MarkDown Formatter", (sender, args) =>
67+
{
68+
UseMarkDownFormatter();
69+
});
70+
6071
SampleController.Current.RegisterNewCommand("Use Custom Formatter", (sender, args) =>
6172
{
6273
UseCustomFormatter();
@@ -88,6 +99,28 @@ private void ResetLayout()
8899
}
89100
}
90101

102+
private void UseRichTextFormatter()
103+
{
104+
if (_toolbar == null)
105+
{
106+
return;
107+
}
108+
109+
var formatter = new RichTextFormatter();
110+
_toolbar.Formatter = formatter;
111+
}
112+
113+
private void UseMarkDownFormatter()
114+
{
115+
if (_toolbar == null)
116+
{
117+
return;
118+
}
119+
120+
var formatter = new MarkDownFormatter();
121+
_toolbar.Formatter = formatter;
122+
}
123+
91124
private void UseCustomFormatter()
92125
{
93126
if (_toolbar == null)

0 commit comments

Comments
 (0)