この手順では、いくつかの AppBar 項目を作成するコードと、C1RichTextBox コントロールのイベントを処理するコードを追加します。
C# コードの書き方
| C# |
コードのコピー
|
|---|---|
using C1.Xaml; using C1.Xaml.RichTextBox; using C1.Xaml.RichTextBox.Documents; using System.Reflection; using Windows.UI.Text; using Windows.UI; using Windows.UI.Popups; |
|
| C# |
コードのコピー
|
|---|---|
| this.InitMorePopup(); | |
C# コードの書き方
| C# |
コードのコピー
|
|---|---|
btnBold.RichTextBox = rtb; btnItalic.RichTextBox = rtb; btnUnderline.RichTextBox = rtb; btnIncreaseFontSize.RichTextBox = rtb; btnDecreaseFontSize.RichTextBox = rtb; btnLeftAlign.RichTextBox = rtb; btnCenterAlign.RichTextBox = rtb; btnRightAlign.RichTextBox = rtb; |
|
C# コードの書き方
| C# |
コードのコピー
|
|---|---|
Assembly asm = typeof(MainPage).GetTypeInfo().Assembly;
Stream stream = asm.GetManifestResourceStream("YourApplicationName.Resources.simple.htm");
var html = new StreamReader(stream).ReadToEnd();
rtb.Html = html;
|
|
C# コードの書き方
| C# |
コードのコピー
|
|---|---|
private async void rtb_RequestNavigate(object sender, RequestNavigateEventArgs e)
{
var md = new MessageDialog("The document is requesting to navigate to " + e.Hyperlink.NavigateUri, "Navigate");
md.Commands.Add(new UICommand("OK", (UICommandInvokedHandler) =>
{
Windows.System.Launcher.LaunchUriAsync(e.Hyperlink.NavigateUri);
}));
md.Commands.Add(new UICommand("Cancel", (UICommandInvokedHandler) =>
{
rtb.Select(e.Hyperlink.ContentStart.TextOffset, e.Hyperlink.ContentRange.Text.Length);
}));
await md.ShowAsync();
|
|
この手順では、C1RichTextBox イベントを処理するコードと、AppBar で使用するいくつかの C1 ツールを作成するコードを追加しました。次の手順では、下部の AppBar のコードを追加します。