Skip to content

Commit 35b42b0

Browse files
committed
Added documentation for RichEditToolbar
1 parent 92e8ba6 commit 35b42b0

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
uid: package-ui-controls-richedittoolbar
3+
title: Using the RichEditToolbar control
4+
---
5+
6+
# Using the RichEditToolbar control
7+
8+
The `MADE.UI.Controls.RichEditToolbar` element is a custom-built UI element that works with [Uno's supported platforms](https://platform.uno/) that provides customizable and extensible collection of buttons that activate rich text features in an associated [RichEditBox](https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Controls.RichEditBox?view=winrt-22000).
9+
10+
Shown below is the visuals for the control in its default state.
11+
12+
<img src="../../images/RichEditToolbar.png" alt="RichEditToolbar with default button options" />
13+
14+
## Example usage
15+
16+
```xml
17+
<Page
18+
x:Class="ChipBoxSample.MainPage"
19+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
20+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
21+
xmlns:controls="using:MADE.UI.Controls"
22+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
23+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
24+
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
25+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
26+
mc:Ignorable="d">
27+
28+
<Grid>
29+
<Grid.RowDefinitions>
30+
<RowDefinition Height="Auto" />
31+
<RowDefinition Height="*" />
32+
</Grid.RowDefinitions>
33+
34+
<controls:RichEditToolbar
35+
x:Name="RichEditToolbarControl"
36+
TargetRichEditBox="{x:Bind RichEditBox}"
37+
ShowFontSizeOptions="True"
38+
ShowTextColorOptions="True"
39+
ShowListStyleOptions="True">
40+
<controls:RichEditToolbar.CustomOptions>
41+
<AppBarSeparator />
42+
<AppBarButton x:Name="SaveButton" Icon="Save" Label="Save" />
43+
<AppBarButton x:Name="UndoButton" Icon="Undo" Label="Undo" />
44+
<AppBarButton x:Name="RedoButton" Icon="Redo" Label="Redo" />
45+
</controls:RichEditToolbar.CustomOptions>
46+
</controls:RichEditToolbar>
47+
48+
<win:RichEditBox x:Name="RichEditBox" Grid.Row="1" />
49+
</Grid>
50+
</Page>
51+
```
52+
53+
## Supporting Uno Platform
54+
55+
Unfortunately, Uno Platform doesn't currently support the use of `RichEditBox`.
56+
57+
The control has been custom built now to structure around the unsupported direct attachment to a `RichEditBox` exposing events that allow a developer to use the control in a different context in Uno Platform applications.
58+
59+
You can listen for these changes by hooking onto the following `RichEditToolbar` events:
60+
61+
- FontSizeChanged
62+
- FontStyleChanged
63+
- TextColorChanged
64+
- ListStyleChanged
65+
66+
These are fired when the user changes the font size, font style, text color, or list style. Each event provides an event argument that provides the new values for that setting.
67+
68+
## Customizing the ChipBox
69+
70+
The control has many customization properties that are exposed to tailor the experience for your application.
71+
72+
### Custom toolbar options
73+
74+
As well as the out-of-the-box options available, the `RichEditToolbar` allows developers to extend the options with additional custom options.
75+
76+
These can be added to the `CustomOptions` collection on the control either via XAML or in code.
77+
78+
```xml
79+
<controls:RichEditToolbar>
80+
<controls:RichEditToolbar.CustomOptions>
81+
<AppBarButton x:Name="SaveButton" Icon="Save" Label="Save" />
82+
<AppBarButton x:Name="UndoButton" Icon="Undo" Label="Undo" />
83+
<AppBarButton x:Name="RedoButton" Icon="Redo" Label="Redo" />
84+
</controls:RichEditToolbar.CustomOptions>
85+
</controls:RichEditToolbar>
86+
```
87+
88+
### Custom text color options
89+
90+
Exposed on the `RichEditToolbar` is a `CustomTextColorOptions` property that allows you to provide your own custom set of colors to display in the text color options panel.
91+
92+
Here's an example of adding these via code.
93+
94+
```csharp
95+
private static readonly IList<RichEditToolbarTextColorOption> CustomTextColorOptions =
96+
new List<RichEditToolbarTextColorOption>
97+
{
98+
new() {Name = "Pastel pink", Color = "#ff80ff"},
99+
new() {Name = "Pastel orange", Color = "#ffc680"},
100+
new() {Name = "Pastel yellow", Color = "#ffff80"},
101+
new() {Name = "Pastel green", Color = "#80ff9e"},
102+
new() {Name = "Pastel blue", Color = "#80d6ff"},
103+
new() {Name = "Pastel purple", Color = "#bcb3ff"},
104+
};
105+
106+
this.RichEditToolbar.CustomTextColorOptions = this.CustomTextColorOptions;
107+
```
108+
109+
### Showing font size options
110+
111+
By default, font size options are shown to the user when using the control out-of-the-box.
112+
113+
If these options are not desired, set the `ShowFontSizeOptions` property to `False`.
114+
115+
### Showing text color options
116+
117+
By default, text color options are shown to the user when using the control out-of-the-box.
118+
119+
If these options are not desired, set the `ShowTextColorOptions` property to `False`.
120+
121+
### Showing list style options
122+
123+
By default, list style options are shown to the user when using the control out-of-the-box.
124+
125+
If these options are not desired, set the `ShowListStyleOptions` property to `False`.

docs/images/RichEditToolbar.png

2.47 KB
Loading

0 commit comments

Comments
 (0)